Skip to content

Commit ffa9ef7

Browse files
committed
Use new ChildProcess.spawn function in gren-lang/node to fix interactivity issues.
1 parent aec63fa commit ffa9ef7

File tree

2 files changed

+8
-25
lines changed

2 files changed

+8
-25
lines changed

gren.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"source-directories": [
55
"src"
66
],
7-
"gren-version": "0.4.0",
7+
"gren-version": "0.4.3",
88
"dependencies": {
99
"direct": {
1010
"gren-lang/core": "5.0.0",
11-
"gren-lang/node": "4.0.0"
11+
"gren-lang/node": "4.1.0"
1212
},
1313
"indirect": {
1414
"gren-lang/url": "4.0.0"

src/Main.gren

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import FileSystem.Path as Path exposing (Path)
1111
import HttpClient
1212
import Bytes exposing (Bytes)
1313
import Terminal
14+
import Process
1415

1516

1617
main : Node.Program Model Msg
@@ -217,7 +218,6 @@ type Msg
217218
= ExistanceChecked (Result FileSystem.Error Path)
218219
| CompilerDownloaded (Result (HttpClient.Error Bytes) (HttpClient.Response Bytes))
219220
| CompilerInstalled (Result FileSystem.Error {})
220-
| CompilerExecuted (Result ChildProcess.FailedRun ChildProcess.SuccessfulRun)
221221

222222

223223
update : Msg -> Model -> { model : Model, command : Cmd Msg }
@@ -241,7 +241,7 @@ update msg model =
241241
{ model = model
242242
, command =
243243
runCompiler model
244-
|> Task.attempt CompilerExecuted
244+
|> Task.execute
245245
}
246246

247247
CompilerDownloaded (Err ((HttpClient.BadStatus res) as err)) ->
@@ -308,22 +308,6 @@ update msg model =
308308
{ model = model
309309
, command =
310310
runCompiler model
311-
|> Task.attempt CompilerExecuted
312-
}
313-
314-
CompilerExecuted (Err output) ->
315-
{ model = model
316-
, command =
317-
Stream.send model.stderr output.stderr
318-
|> Task.andThen (\_ -> Node.exitWithCode output.exitCode)
319-
|> Task.execute
320-
}
321-
322-
CompilerExecuted (Ok output) ->
323-
{ model = model
324-
, command =
325-
Stream.send model.stdout output.stdout
326-
|> Task.andThen (\_ -> Stream.send model.stderr output.stderr)
327311
|> Task.execute
328312
}
329313

@@ -335,7 +319,7 @@ downloadBinary permission url =
335319
|> HttpClient.send permission
336320

337321

338-
runCompiler : Model -> Task ChildProcess.FailedRun ChildProcess.SuccessfulRun
322+
runCompiler : Model -> Task x Process.Id
339323
runCompiler model =
340324
let
341325
colorEnvVar =
@@ -344,9 +328,8 @@ runCompiler model =
344328
else
345329
Dict.singleton "NO_COLOR" "1"
346330
in
347-
ChildProcess.run model.cpPermission (model.pathToString model.localPath) model.args <|
348-
{ ChildProcess.defaultRunOptions
349-
| maximumBytesWrittenToStreams = 1024 * 1024 -- 1Mb
350-
, environmentVariables =
331+
ChildProcess.spawn model.cpPermission (model.pathToString model.localPath) model.args <|
332+
{ ChildProcess.defaultSpawnOptions
333+
| environmentVariables =
351334
ChildProcess.MergeWithEnvironmentVariables colorEnvVar
352335
}

0 commit comments

Comments
 (0)