mirror of
https://github.com/nmattia/niv.git
synced 2024-09-19 11:27:40 +03:00
Don't forward stderr
This commit is contained in:
parent
83d7e3ec5b
commit
43747ff10b
@ -19,9 +19,9 @@ import Data.Maybe (fromMaybe)
|
|||||||
import Data.String.QQ (s)
|
import Data.String.QQ (s)
|
||||||
import Niv.GitHub
|
import Niv.GitHub
|
||||||
import Niv.Update
|
import Niv.Update
|
||||||
import System.Exit (exitFailure)
|
import System.Exit (exitFailure, ExitCode(ExitSuccess))
|
||||||
import System.FilePath ((</>), takeDirectory)
|
import System.FilePath ((</>), takeDirectory)
|
||||||
import System.Process (readProcess)
|
import System.Process (readProcessWithExitCode)
|
||||||
import UnliftIO
|
import UnliftIO
|
||||||
import qualified Data.Aeson as Aeson
|
import qualified Data.Aeson as Aeson
|
||||||
import qualified Data.Aeson.Encode.Pretty as AesonPretty
|
import qualified Data.Aeson.Encode.Pretty as AesonPretty
|
||||||
@ -524,12 +524,14 @@ abort msg = do
|
|||||||
exitFailure
|
exitFailure
|
||||||
|
|
||||||
nixPrefetchURL :: Bool -> T.Text -> IO T.Text
|
nixPrefetchURL :: Bool -> T.Text -> IO T.Text
|
||||||
nixPrefetchURL unpack (T.unpack -> url) =
|
nixPrefetchURL unpack (T.unpack -> url) = do
|
||||||
lines <$> readProcess "nix-prefetch-url" args "" >>=
|
(exitCode, sout, serr) <- runNixPrefetch
|
||||||
\case
|
case (exitCode, lines sout) of
|
||||||
(l:_) -> pure (T.pack l)
|
(ExitSuccess, l:_) -> pure $ T.pack l
|
||||||
_ -> abortNixPrefetchExpectedOutput
|
_ -> abortNixPrefetchExpectedOutput (T.pack sout) (T.pack serr)
|
||||||
where args = if unpack then ["--unpack", url] else [url]
|
where
|
||||||
|
args = if unpack then ["--unpack", url] else [url]
|
||||||
|
runNixPrefetch = readProcessWithExitCode "nix-prefetch-url" args ""
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Files and their content
|
-- Files and their content
|
||||||
@ -676,15 +678,15 @@ abortUpdateFailed errs = abort $ T.unlines $
|
|||||||
pname <> ": " <> tshow e
|
pname <> ": " <> tshow e
|
||||||
) errs
|
) errs
|
||||||
|
|
||||||
abortNixPrefetchExpectedOutput :: IO a
|
abortNixPrefetchExpectedOutput :: T.Text -> T.Text -> IO a
|
||||||
abortNixPrefetchExpectedOutput = abort [s|
|
abortNixPrefetchExpectedOutput sout serr = abort $ [s|
|
||||||
Could not read the output of 'nix-prefetch-url'. This is a bug. Please create a
|
Could not read the output of 'nix-prefetch-url'. This is a bug. Please create a
|
||||||
ticket:
|
ticket:
|
||||||
|
|
||||||
https://github.com/nmattia/niv/issues/new
|
https://github.com/nmattia/niv/issues/new
|
||||||
|
|
||||||
Thanks! I'll buy you a beer.
|
Thanks! I'll buy you a beer.
|
||||||
|]
|
|] <> T.unlines ["stdout: ", sout, "stderr: ", serr]
|
||||||
|
|
||||||
tshow :: Show a => a -> T.Text
|
tshow :: Show a => a -> T.Text
|
||||||
tshow = T.pack . show
|
tshow = T.pack . show
|
||||||
|
Loading…
Reference in New Issue
Block a user