-- | Produce strict 'S.ByteString's from the stderr and stdout of a process.
--
-- Throws a 'ReadProcessException' exception if the process fails.
readProcessStderrStdout :: (MonadIO m, MonadLogger m, MonadBaseControl IO m)
                        => Maybe (Path Abs Dir) -- ^ Optional directory to run in
                        -> EnvOverride
                        -> String -- ^ Command
                        -> [String] -- ^ Command line arguments
                        -> m (S.ByteString, S.ByteString)
readProcessStderrStdout wd menv name args = do
  (e, o) <- sinkProcessStderrStdout wd menv name args CL.consume CL.consume
  liftIO $ (,) <$> evaluate (S.concat e) <*> evaluate (S.concat o)

-- | An exception while trying to read from process.
readProcessStderrStdout :: (MonadIO m, MonadLogger m, MonadBaseControl IO m)
                        => Maybe (Path Abs Dir) -- ^ Optional directory to run in
                        -> EnvOverride
                        -> String -- ^ Command
                        -> [String] -- ^ Command line arguments
                        -> m (S.ByteString, S.ByteString)
readProcessStderrStdout wd menv name args = do
  (e, o) <- sinkProcessStderrStdout wd menv name args CL.consume CL.consume
  liftIO $ (,) <$> evaluate (S.concat e) <*> evaluate (S.concat o)

-- | An exception while trying to read from process.
readProcessStderrStdout wd menv name args = do
  (e, o) <- sinkProcessStderrStdout wd menv name args CL.consume CL.consume
  liftIO $ (,) <$> evaluate (S.concat e) <*> evaluate (S.concat o)

-- | An exception while trying to read from process.