@@ -1,6 +1,10 @@
1+{-# OPTIONS_GHC -Wall #-}
1module Elm.Internal.Paths where
2module Elm.Internal.Paths where
3−import System.IO.Unsafe
4+import System.Directory (doesDirectoryExist)
5+import System.Environment (getEnv)
6+import System.FilePath ((</>))
7+import System.IO.Unsafe (unsafePerformIO)
4import qualified Paths_Elm as This
8import qualified Paths_Elm as This
6-- |Name of directory for all of a project's dependencies.
10-- |Name of directory for all of a project's dependencies.
@@ -15,9 +19,20 @@ dependencyFile = "elm_dependencies.json"
15{-# NOINLINE runtime #-}
19{-# NOINLINE runtime #-}
16-- |The absolute path to Elm's runtime system.
20-- |The absolute path to Elm's runtime system.
17runtime :: FilePath
21runtime :: FilePath
18−runtime = unsafePerformIO $ This.getDataFileName "elm-runtime.js"
22+runtime = unsafePerformIO $ getDataFile "elm-runtime.js"
20{-# NOINLINE docs #-}
24{-# NOINLINE docs #-}
21-- |The absolute path to Elm's core library documentation.
25-- |The absolute path to Elm's core library documentation.
22docs :: FilePath
26docs :: FilePath
27+docs = unsafePerformIO $ getDataFile "docs.json"
29+-- |The absolute path to a data file
30+getDataFile :: FilePath -> IO FilePath
23−docs = unsafePerformIO $ This.getDataFileName "docs.json"
32+ path <- This.getDataFileName name
33+ exists <- doesDirectoryExist path
37+ env <- getEnv "ELM_HOME"
38+ return (env </> name)