on master help sign in
Fix for "trying to write to a file in a non-existant directory"
commit272557d785987b909971c8a7a0b4ca73c8a6cabd authorEvan Czaplicki <info@elm-lang.org> dateSat 27 Jul 2013, 00:39 (13 years ago) parentfd63aff
1 file changed+8−5
compiler/Compiler.hs+8−5
compiler/Compiler.hs+8−5
@@ -92,11 +92,13 @@ buildFile flags moduleNum numModules interfaces filePath =
9292 where
9393 alreadyCompiled :: IO Bool
9494 alreadyCompiled = do
95− exists <- doesFileExist (elmo flags filePath)
96− if not exists then return False
97− else do tsrc <- getModificationTime filePath
98− tint <- getModificationTime (elmo flags filePath)
99− return (tsrc < tint)
95+ existsi <- doesFileExist (elmi flags filePath)
96+ existso <- doesFileExist (elmo flags filePath)
97+ if not existsi || not existso
98+ then return False
99+ else do tsrc <- getModificationTime filePath
100+ tint <- getModificationTime (elmo flags filePath)
101+ return (tsrc < tint)
100102
101103 number :: String
102104 number = "[" ++ show moduleNum ++ " of " ++ show numModules ++ "]"
@@ -123,6 +125,7 @@ buildFile flags moduleNum numModules interfaces filePath =
123125 iAdts = datatypes metaModule,
124126 iAliases = aliases metaModule
125127 }
128+ createDirectoryIfMissing True . dropFileName $ elmi flags filePath
126129 Binary.encodeFile (elmi flags filePath) interface
127130 let js = jsModule metaModule
128131 writeFile (elmo flags filePath) js