Skip to content

Commit

Permalink
Get rid of Elm.Utils.getAssets and ELM_HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
process-bot committed Apr 20, 2016
1 parent 664751a commit dee708a
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions src/Elm/Utils.hs
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Elm.Utils
( (|>), (<|)
, getAsset
, run, unwrappedRun
, CommandError(..)
, isDeclaration
) where

import Control.Monad.Except (MonadError, MonadIO, liftIO, throwError)
import qualified Data.List as List
import System.Directory (doesFileExist)
import System.Environment (getEnv)
import System.Exit (ExitCode(ExitSuccess, ExitFailure))
import System.FilePath ((</>))
import System.IO.Error (tryIOError)
import System.Process (readProcessWithExitCode)

import qualified AST.Pattern as Pattern
import qualified Elm.Compiler.Version as Version
import qualified Elm.Package as Pkg
import qualified Parse.Helpers as Parse
import qualified Parse.Expression as Parse
import qualified Reporting.Annotation as A
Expand Down Expand Up @@ -103,52 +95,6 @@ missingExe command =



-- GET STATIC ASSETS

{-| Get the absolute path to a data file. If you install with cabal it will look
in a directory generated by cabal. If that is not found, it will look for the
directory pointed to by the environment variable ELM_HOME.
-}
getAsset :: String -> (FilePath -> IO FilePath) -> FilePath -> IO FilePath
getAsset project getDataFileName name =
do path <- getDataFileName name
exists <- doesFileExist path
if exists
then return path
else do
environment <- tryIOError (getEnv "ELM_HOME")
case environment of
Right env ->
return (env </> project </> name)

Left _ ->
fail (errorNotFound name)


errorNotFound :: FilePath -> String
errorNotFound name =
unlines
[ "Unable to find the ELM_HOME environment variable when searching"
, "for the " ++ name ++ " file."
, ""
, "If you installed Elm Platform with the Mac or Windows installer, it looks like"
, "ELM_HOME was not set automatically. Look up how to set environment variables"
, "on your platform and set ELM_HOME to the directory that contains Elm's static"
, "files:"
, ""
, " * On Mac it is /usr/local/share/elm"
, " * On Windows it is one of the following:"
, " C:/Program Files/Elm Platform/" ++ (Pkg.versionToString Version.version) ++ "/share"
, " C:/Program Files (x86)/Elm Platform/" ++ (Pkg.versionToString Version.version) ++ "/share"
, ""
, "If you installed using npm, you have to set ELM_HOME to a certain directory"
, "of the form .../node_modules/elm/share"
, ""
, "If it seems like a more complex issue, please report it here:"
, " <https://github.com/elm-lang/elm-platform/issues>"
]


-- DECL CHECKER

isDeclaration :: String -> Maybe String
Expand Down

0 comments on commit dee708a

Please sign in to comment.