on master help sign in
Get rid of Elm.Utils.getAssets and ELM_HOME
dee708aEvan Czaplicki
src/Elm/Utils.hs−54
@@ -1,9 +1,7 @@
1{-# OPTIONS_GHC -Wall #-}
1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE MultiParamTypeClasses #-}
4module Elm.Utils
3module Elm.Utils
5 ( (|>), (<|)
4 ( (|>), (<|)
6− , getAsset
7 , run, unwrappedRun
5 , run, unwrappedRun
8 , CommandError(..)
6 , CommandError(..)
9 , isDeclaration
7 , isDeclaration
@@ -11,16 +9,10 @@ module Elm.Utils
11
9
12import Control.Monad.Except (MonadError, MonadIO, liftIO, throwError)
10import Control.Monad.Except (MonadError, MonadIO, liftIO, throwError)
13import qualified Data.List as List
11import qualified Data.List as List
14−import System.Directory (doesFileExist)
15−import System.Environment (getEnv)
16import System.Exit (ExitCode(ExitSuccess, ExitFailure))
12import System.Exit (ExitCode(ExitSuccess, ExitFailure))
17−import System.FilePath ((</>))
18−import System.IO.Error (tryIOError)
19import System.Process (readProcessWithExitCode)
13import System.Process (readProcessWithExitCode)
20
14
21import qualified AST.Pattern as Pattern
15import qualified AST.Pattern as Pattern
22−import qualified Elm.Compiler.Version as Version
23−import qualified Elm.Package as Pkg
24import qualified Parse.Helpers as Parse
16import qualified Parse.Helpers as Parse
25import qualified Parse.Expression as Parse
17import qualified Parse.Expression as Parse
26import qualified Reporting.Annotation as A
18import qualified Reporting.Annotation as A
@@ -103,52 +95,6 @@ missingExe command =
103
95
104
96
105
97
106−-- GET STATIC ASSETS
107−
108−{-| Get the absolute path to a data file. If you install with cabal it will look
109−in a directory generated by cabal. If that is not found, it will look for the
110−directory pointed to by the environment variable ELM_HOME.
111−-}
112−getAsset :: String -> (FilePath -> IO FilePath) -> FilePath -> IO FilePath
113−getAsset project getDataFileName name =
114− do path <- getDataFileName name
115− exists <- doesFileExist path
116− if exists
117− then return path
118− else do
119− environment <- tryIOError (getEnv "ELM_HOME")
120− case environment of
121− Right env ->
122− return (env </> project </> name)
123−
124− Left _ ->
125− fail (errorNotFound name)
126−
127−
128−errorNotFound :: FilePath -> String
129−errorNotFound name =
130− unlines
131− [ "Unable to find the ELM_HOME environment variable when searching"
132− , "for the " ++ name ++ " file."
133− , ""
134− , "If you installed Elm Platform with the Mac or Windows installer, it looks like"
135− , "ELM_HOME was not set automatically. Look up how to set environment variables"
136− , "on your platform and set ELM_HOME to the directory that contains Elm's static"
137− , "files:"
138− , ""
139− , " * On Mac it is /usr/local/share/elm"
140− , " * On Windows it is one of the following:"
141− , " C:/Program Files/Elm Platform/" ++ (Pkg.versionToString Version.version) ++ "/share"
142− , " C:/Program Files (x86)/Elm Platform/" ++ (Pkg.versionToString Version.version) ++ "/share"
143− , ""
144− , "If you installed using npm, you have to set ELM_HOME to a certain directory"
145− , "of the form .../node_modules/elm/share"
146− , ""
147− , "If it seems like a more complex issue, please report it here:"
148− , " <https://github.com/elm-lang/elm-platform/issues>"
149− ]
150−
151−
152-- DECL CHECKER
98-- DECL CHECKER
153
99
154isDeclaration :: String -> Maybe String
100isDeclaration :: String -> Maybe String