on master help sign in
Fix for "trying to write to a file in a non-existant directory"
272557dEvan Czaplicki
compiler/Compiler.hs+8−5
@@ -92,11 +92,13 @@ buildFile flags moduleNum numModules interfaces filePath =
92 where
92 where
93 alreadyCompiled :: IO Bool
93 alreadyCompiled :: IO Bool
94 alreadyCompiled = do
94 alreadyCompiled = do
95+ existsi <- doesFileExist (elmi flags filePath)
95− exists <- doesFileExist (elmo flags filePath)
96+ existso <- doesFileExist (elmo flags filePath)
97+ if not existsi || not existso
96− if not exists then return False
98+ then return False
97− else do tsrc <- getModificationTime filePath
99+ else do tsrc <- getModificationTime filePath
98− tint <- getModificationTime (elmo flags filePath)
100+ tint <- getModificationTime (elmo flags filePath)
99− return (tsrc < tint)
101+ return (tsrc < tint)
100
102
101 number :: String
103 number :: String
102 number = "[" ++ show moduleNum ++ " of " ++ show numModules ++ "]"
104 number = "[" ++ show moduleNum ++ " of " ++ show numModules ++ "]"
@@ -123,6 +125,7 @@ buildFile flags moduleNum numModules interfaces filePath =
123 iAdts = datatypes metaModule,
125 iAdts = datatypes metaModule,
124 iAliases = aliases metaModule
126 iAliases = aliases metaModule
125 }
127 }
128+ createDirectoryIfMissing True . dropFileName $ elmi flags filePath
126 Binary.encodeFile (elmi flags filePath) interface
129 Binary.encodeFile (elmi flags filePath) interface
127 let js = jsModule metaModule
130 let js = jsModule metaModule
128 writeFile (elmo flags filePath) js
131 writeFile (elmo flags filePath) js