aboutsummaryrefslogtreecommitdiffstats
path: root/app/Process.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Process.hs')
-rw-r--r--app/Process.hs12
1 files changed, 4 insertions, 8 deletions
diff --git a/app/Process.hs b/app/Process.hs
index 9ce5e46..2b3eaf6 100644
--- a/app/Process.hs
+++ b/app/Process.hs
@@ -11,34 +11,30 @@ module Process
)
where
-import Control.Exception (Exception, throwIO)
+import Control.Exception (throwIO)
import Data.ByteString.Lazy.Char8 qualified as LB
import Data.List (intercalate)
import Data.String (fromString)
import Data.Text qualified as T
import Data.Text.Lazy qualified as LT
import Data.Text.Lazy.Encoding qualified as LT
+import Exception qualified as E
import System.Exit (ExitCode (ExitSuccess))
import System.Process.Typed (ProcessConfig, StreamSpec, StreamType (STInput), byteStringInput, readProcess, readProcessStderr)
-data ProcessException = ProcessException String ExitCode LB.ByteString
- deriving (Show)
-
-instance Exception ProcessException
-
sh :: ProcessConfig stdin stdoutIgnored stderr -> IO LB.ByteString
sh processConfig = do
(exitCode, out, err) <- readProcess processConfig
if exitCode == ExitSuccess
then pure out
- else throwIO $ ProcessException (show processConfig) exitCode err
+ else throwIO $ E.ProcessException (show processConfig) exitCode err
sh_ :: ProcessConfig stdin stdoutIgnored stderr -> IO ()
sh_ processConfig = do
(exitCode, err) <- readProcessStderr processConfig
if exitCode == ExitSuccess
then pure ()
- else throwIO $ ProcessException (show processConfig) exitCode err
+ else throwIO $ E.ProcessException (show processConfig) exitCode err
class Quotable a where
quote :: a -> String