Only supress stderr on success
This commit is contained in:
parent
4389dea800
commit
8f3fb2a7d7
@ -18,9 +18,10 @@ import Data.Char (isSpace,isAlphaNum)
|
|||||||
import Data.List (isPrefixOf, intercalate)
|
import Data.List (isPrefixOf, intercalate)
|
||||||
import Data.Maybe (listToMaybe, maybeToList)
|
import Data.Maybe (listToMaybe, maybeToList)
|
||||||
import Language.Haskell.GhcMod.Types
|
import Language.Haskell.GhcMod.Types
|
||||||
import Language.Haskell.GhcMod.Utils
|
|
||||||
import System.FilePath ((</>))
|
import System.FilePath ((</>))
|
||||||
import System.Process (readProcess)
|
import System.Process (readProcessWithExitCode)
|
||||||
|
import System.IO (hPutStrLn,stderr)
|
||||||
|
import System.Exit (ExitCode(..))
|
||||||
import Text.ParserCombinators.ReadP (ReadP, char, between, sepBy1, many1, string, choice, eof)
|
import Text.ParserCombinators.ReadP (ReadP, char, between, sepBy1, many1, string, choice, eof)
|
||||||
import qualified Text.ParserCombinators.ReadP as P
|
import qualified Text.ParserCombinators.ReadP as P
|
||||||
|
|
||||||
@ -67,7 +68,13 @@ ghcPkgList dbs = map fst3 <$> ghcPkgListEx dbs
|
|||||||
|
|
||||||
ghcPkgListEx :: [GhcPkgDb] -> IO [Package]
|
ghcPkgListEx :: [GhcPkgDb] -> IO [Package]
|
||||||
ghcPkgListEx dbs = do
|
ghcPkgListEx dbs = do
|
||||||
output <- suppressStderr $ readProcess "ghc-pkg" opts ""
|
(rv,output,err) <- readProcessWithExitCode "ghc-pkg" opts ""
|
||||||
|
case rv of
|
||||||
|
ExitFailure val -> do
|
||||||
|
hPutStrLn stderr err
|
||||||
|
fail $ "ghc-pkg " ++ intercalate " " opts ++ " (exit " ++ show val ++ ")"
|
||||||
|
ExitSuccess -> return ()
|
||||||
|
|
||||||
return $ parseGhcPkgOutput $ lines output
|
return $ parseGhcPkgOutput $ lines output
|
||||||
where
|
where
|
||||||
opts = ["list", "-v"] ++ ghcPkgDbStackOpts dbs
|
opts = ["list", "-v"] ++ ghcPkgDbStackOpts dbs
|
||||||
|
Loading…
Reference in New Issue
Block a user