Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions hie-plugin-api/Haskell/Ide/Engine/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Control.Exception
import System.FilePath
import System.Directory (getCurrentDirectory, canonicalizePath, findExecutable)
import System.Exit
import System.Process (readCreateProcessWithExitCode, shell)
import System.Process (readCreateProcessWithExitCode, shell, CreateProcess(..))

import Haskell.Ide.Engine.Logger

Expand Down Expand Up @@ -102,7 +102,7 @@ execProjectGhc crdl args = do
ghcOutput <- if isStackCradle crdl && isStackInstalled
then do
logm $ "Executing Stack GHC with args: " <> unwords args
catch (Just <$> tryCommand stackCmd) $ \(_ :: IOException) -> do
catch (Just <$> tryCommand crdl stackCmd) $ \(_ :: IOException) -> do
errorm $ "Command `" ++ stackCmd ++"` failed."
execWithGhc
-- The command `cabal v2-exec -v0 ghc` only works if the project has been
Expand All @@ -112,7 +112,7 @@ execProjectGhc crdl args = do
--
-- else if isCabalCradle crdl && isCabalInstalled then do
-- let cmd = "cabal v2-exec -v0 ghc -- " ++ unwords args
-- catch (Just <$> tryCommand cmd) $ \(_ ::IOException) -> do
-- catch (Just <$> tryCommand crdl cmd) $ \(_ ::IOException) -> do
-- errorm $ "Command `" ++ cmd ++ "` failed."
-- return Nothing
else do
Expand All @@ -125,13 +125,14 @@ execProjectGhc crdl args = do
plainCmd = "ghc " ++ unwords args

execWithGhc =
catch (Just <$> tryCommand plainCmd) $ \(_ :: IOException) -> do
catch (Just <$> tryCommand crdl plainCmd) $ \(_ :: IOException) -> do
errorm $ "Command `" ++ plainCmd ++"` failed."
return Nothing

tryCommand :: String -> IO String
tryCommand cmd = do
(code, sout, serr) <- readCreateProcessWithExitCode (shell cmd) ""
tryCommand :: Cradle CabalHelper -> String -> IO String
tryCommand crdl cmd = do
let p = (shell cmd) { cwd = Just (cradleRootDir crdl) }
(code, sout, serr) <- readCreateProcessWithExitCode p ""
case code of
ExitFailure e -> do
let errmsg = concat
Expand Down