Commit f4b7fb59 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Allow using ihaskell without stack...

parent 716d8a6b
......@@ -18,6 +18,7 @@ import Data.Aeson
import System.Directory
import System.Process (readProcess, readProcessWithExitCode)
import System.Exit (exitSuccess, ExitCode(ExitSuccess))
import Control.Exception (try, SomeException)
import System.Environment (getArgs)
#if MIN_VERSION_ghc(7,8,0)
import System.Environment (setEnv)
......@@ -116,11 +117,14 @@ runKernel kernelOpts profileSrc = do
dir <- getIHaskellDir
Stdin.recordKernelProfile dir profile
#if MIN_VERSION_ghc(7,8,0)
-- Detect if we have stack
(exitCode, stackStdout, _) <- readProcessWithExitCode "stack" [] ""
let stack = exitCode == ExitSuccess && "The Haskell Tool Stack" `isInfixOf` stackStdout
runResult <- try $ readProcessWithExitCode "stack" [] ""
let stack =
case runResult :: Either SomeException (ExitCode, String, String) of
Left _ -> False
Right (exitCode, stackStdout, _) -> exitCode == ExitSuccess && "The Haskell Tool Stack" `isInfixOf` stackStdout
#if MIN_VERSION_ghc(7,8,0)
-- If we're in a stack directory, use `stack` to set the environment
-- We can't do this with base <= 4.6 because setEnv doesn't exist.
when stack $ do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment