Skip to content

Commit 8b4f30d

Browse files
committed
Updates for newer version of node-streams library.
1 parent 31e7def commit 8b4f30d

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

packages.dhall

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ in upstream
66
with node-buffer.version = "v9.0.0"
77
with node-child-process.version = "v11.0.0"
88
with node-fs.version = "v9.1.0"
9-
with node-process.version = "v11.2.0"
9+
with node-process.version = "v11.2.0"
10+
with node-streams.version = "v9.0.0"

src/Dotenv/Internal/ChildProcess.purs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Control.Monad.Error.Class (throwError)
1414
import Data.Either (Either(..))
1515
import Data.Maybe (Maybe(..))
1616
import Effect.Aff (Aff, effectCanceler, makeAff)
17+
import Effect.Class (liftEffect)
1718
import Effect.Exception (error)
1819
import Effect.Ref as Ref
1920
import Node.ChildProcess (errorH, exitH)
@@ -22,8 +23,7 @@ import Node.ChildProcess.Types (Exit(..), KillSignal, stringSignal)
2223
import Node.Encoding (Encoding(..))
2324
import Node.Errors.SystemError as OS
2425
import Node.EventEmitter (on_)
25-
import Node.Stream (onDataString)
26-
import Node.Stream as NS
26+
import Node.Stream (dataHStr, setEncoding)
2727
import Run (Run, lift)
2828
import Type.Proxy (Proxy(..))
2929

@@ -74,23 +74,18 @@ spawn'
7474
, stderr :: String
7575
, exit :: Exit
7676
}
77-
spawn' encoding killSignal { cmd, args, stdin } = makeAff \cb -> do
77+
spawn' encoding killSignal { cmd, args } = makeAff \cb -> do
7878
stdoutRef <- Ref.new ""
7979
stderrRef <- Ref.new ""
8080

8181
process <- CP.spawn cmd args
8282

83-
case stdin of
84-
Just input -> do
85-
let write = CP.stdin process
86-
void $ NS.writeString write UTF8 input \_ -> do
87-
NS.end write (\_ -> mempty)
88-
Nothing -> pure unit
89-
90-
onDataString (CP.stdout process) encoding \string ->
83+
liftEffect $ setEncoding (CP.stdout process) encoding
84+
CP.stdout process # on_ dataHStr \string ->
9185
Ref.modify_ (_ <> string) stdoutRef
9286

93-
onDataString (CP.stderr process) encoding \string ->
87+
liftEffect $ setEncoding (CP.stderr process) encoding
88+
CP.stderr process # on_ dataHStr \string ->
9489
Ref.modify_ (_ <> string) stderrRef
9590

9691
process # on_ errorH \err ->

0 commit comments

Comments
 (0)