'debug' shouldn't fail if 'cabal' is not installed

which seems to be more common that you'd think
This commit is contained in:
Daniel Gröber 2016-05-11 15:27:11 +02:00
parent 3ae9204b95
commit 7e05c15219

View File

@ -9,6 +9,7 @@ import qualified Data.Set as Set
import Data.Char import Data.Char
import Data.Version import Data.Version
import Data.List.Split import Data.List.Split
import System.Directory
import Text.PrettyPrint import Text.PrettyPrint
import Language.Haskell.GhcMod.Monad import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
@ -76,8 +77,14 @@ cabalDebug = do
srcOpts = Map.map gmcGhcSrcOpts mcs srcOpts = Map.map gmcGhcSrcOpts mcs
readProc <- gmReadProcess readProc <- gmReadProcess
cabalInstVersion <- liftIO $ cabalExists <- liftIO $ (/=Nothing) <$> findExecutable "cabal"
cabalInstVersion <-
if cabalExists
then liftIO $
dropWhileEnd isSpace <$> readProc "cabal" ["--numeric-version"] "" dropWhileEnd isSpace <$> readProc "cabal" ["--numeric-version"] ""
else return ""
packages <- liftIO $ readProc "ghc-pkg" ["list", "--simple-output"] "" packages <- liftIO $ readProc "ghc-pkg" ["list", "--simple-output"] ""
let cabalPackages = filter ((== ["Cabal"]) . take 1 . splitOn "-") $ splitWhen isSpace packages let cabalPackages = filter ((== ["Cabal"]) . take 1 . splitOn "-") $ splitWhen isSpace packages