module Git.Fmt.Process (
run,
) where
import Control.Monad.IO.Class
import Control.Monad.Logger
import Data.Text hiding (unwords)
import System.Exit
import System.Process as System
run :: (MonadIO m, MonadLogger m) => FilePath -> [String] -> m String
run cmd args = do
$(logDebug) $ pack (unwords $ cmd:args)
(exitCode, stdout, stderr) <- liftIO $ System.readProcessWithExitCode cmd args ""
if exitCode == ExitSuccess
then return stdout
else $(logError) (pack stderr) >> liftIO (exitWith $ ExitFailure 1)