|
|
@@ -0,0 +1,29 @@
|
|
|
+module Main where
|
|
|
+
|
|
|
+import Prelude
|
|
|
+
|
|
|
+import Data.Maybe (Maybe(..))
|
|
|
+import Effect (Effect)
|
|
|
+import Effect.Class.Console (log)
|
|
|
+import Node.Buffer (toString)
|
|
|
+import Node.ChildProcess (ExecResult)
|
|
|
+import Node.ChildProcess as ChildProcess
|
|
|
+import Node.Encoding (Encoding(..))
|
|
|
+import Node.Errors.SystemError (code, message)
|
|
|
+
|
|
|
+
|
|
|
+main :: Effect Unit
|
|
|
+main = do
|
|
|
+ log "hello"
|
|
|
+ _ <- ChildProcess.exec' "pwd" identity readExec
|
|
|
+ _ <- ChildProcess.exec' "touch /test.log" identity readExec
|
|
|
+ pure unit
|
|
|
+
|
|
|
+readExec ∷ ExecResult → Effect Unit
|
|
|
+readExec {error: Nothing, stdout, stderr} = do
|
|
|
+ log "OK !"
|
|
|
+ out <- toString UTF8 stdout
|
|
|
+ log out
|
|
|
+
|
|
|
+readExec {error: Just err, stdout, stderr} = do
|
|
|
+ log $ "error ! [" <> code err <> "], " <> message err
|