on master help sign in
Make sure that `createDirectoryIfMissing` is called for included js files

All responsibility falls on @seliopou :P

commitd4def20462a297cc87904e4c6c947c0d2145c783 authorEvan Czaplicki <info@elm-lang.org> dateMon 23 Sep 2013, 16:24 (13 years ago) parent017f96b
1 file changed+9−8
compiler/Compiler.hs+9−8
compiler/Compiler.hs+9−8
@@ -180,19 +180,20 @@ build flags rootFile = do
180180 let ifaces = if noPrelude then Map.empty else Prelude.interfaces
181181 (moduleName, interfaces) <- buildFiles flags (length files) ifaces "" files
182182 js <- foldM appendToOutput "" files
183− case only_js flags of
183+
184+ (extension, code) <- case only_js flags of
184185 True -> do
185186 putStr "Generating JavaScript ... "
186− writeFile (buildPath flags rootFile "js") (genJs js)
187− putStrLn "Done"
187+ return ("js", genJs js)
188188 False -> do
189189 putStr "Generating HTML ... "
190190 runtime <- getRuntime flags
191− let html = genHtml $ createHtml runtime (takeBaseName rootFile) (sources js) moduleName ""
192− htmlFile = buildPath flags rootFile "html"
193− createDirectoryIfMissing True (takeDirectory htmlFile)
194− writeFile htmlFile html
195− putStrLn "Done"
191+ return ("html", genHtml $ createHtml runtime (takeBaseName rootFile) (sources js) moduleName "")
192+
193+ let targetFile = buildPath flags rootFile extension
194+ createDirectoryIfMissing True (takeDirectory targetFile)
195+ writeFile targetFile code
196+ putStrLn "Done"
196197
197198 where
198199 appendToOutput :: String -> FilePath -> IO String