@@ -1,9 +1,7 @@
11{-# OPTIONS_GHC -Wall #-}
22{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE MultiParamTypeClasses #-}
43module Elm.Utils
54 ( (|>), (<|)
6− , getAsset
75 , run, unwrappedRun
86 , CommandError(..)
97 , isDeclaration
@@ -11,16 +9,10 @@ module Elm.Utils
119
1210import Control.Monad.Except (MonadError, MonadIO, liftIO, throwError)
1311import qualified Data.List as List
14−import System.Directory (doesFileExist)
15−import System.Environment (getEnv)
1612import System.Exit (ExitCode(ExitSuccess, ExitFailure))
17−import System.FilePath ((</>))
18−import System.IO.Error (tryIOError)
1913import System.Process (readProcessWithExitCode)
2014
2115import qualified AST.Pattern as Pattern
22−import qualified Elm.Compiler.Version as Version
23−import qualified Elm.Package as Pkg
2416import qualified Parse.Helpers as Parse
2517import qualified Parse.Expression as Parse
2618import qualified Reporting.Annotation as A
@@ -69,7 +61,7 @@ run command args =
6961
7062 message err =
7163 case err of
72− CommandFailed stderr stdout ->
64+ CommandFailed stdout stderr ->
7365 stdout ++ stderr
7466
7567 MissingExe msg ->
@@ -103,52 +95,6 @@ missingExe command =
10395
10496
10597
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−
15298-- DECL CHECKER
15399
154100isDeclaration :: String -> Maybe String