@@ -1,73 +0,0 @@
2−module Build.Utils where
4−import Control.Monad.Error
5−import System.Directory (doesFileExist)
6−import System.Environment (getEnv)
7−import System.FilePath ((</>), replaceExtension)
8−import System.IO.Error (tryIOError)
9−import System.IO.Unsafe (unsafePerformIO)
10−import qualified Build.Flags as Flag
11−import qualified Build.Print as Print
12−import qualified Paths_Elm as This
14−buildPath :: Flag.Flags -> FilePath -> String -> FilePath
15−buildPath flags filePath ext =
16− Flag.build_dir flags </> replaceExtension filePath ext
18−cachePath :: Flag.Flags -> FilePath -> String -> FilePath
19−cachePath flags filePath ext =
20− Flag.cache_dir flags </> replaceExtension filePath ext
22−elmo :: Flag.Flags -> FilePath -> FilePath
24− cachePath flags filePath "elmo"
26−elmi :: Flag.Flags -> FilePath -> FilePath
28− cachePath flags filePath "elmi"
31−{-# NOINLINE runtime #-}
32−-- |The absolute path to Elm's runtime system.
35− unsafePerformIO $ getDataFile "elm-runtime.js"
38−-- |The absolute path to a data file
39−getDataFile :: FilePath -> IO FilePath
41− path <- This.getDataFileName name
42− exists <- doesFileExist path
46− environment <- tryIOError (getEnv "ELM_HOME")
48− Right env -> return (env </> "compiler" </> name)
51− [ "Unable to find the ELM_HOME environment variable when searching"
52− , "for the " ++ name ++ " file."
54− , "If you installed Elm Platform with the Mac or Windows installer, it looks like"
55− , "ELM_HOME was not set automatically. Look up how to set environment variables"
56− , "on your platform and set ELM_HOME to the directory that contains Elm's static"
59− , " * On Mac it is /usr/local/share/elm"
60− , " * On Windows it is one of the following:"
61− , " C:/Program Files/Elm Platform/0.13/share"
62− , " C:/Program Files (x86)/Elm Platform/0.13/share"
64− , "If it seems like a more complex issue, please report it here:"
65− , " <https://github.com/elm-lang/elm-platform/issues>"
68−run :: ErrorT String IO a -> IO a
70− either <- runErrorT command
72− Left err -> Print.failure err
73− Right result -> return result