@@ -170,10 +170,10 @@ type Msg
170
170
, downloadResult : Result (HttpClient.Error Bytes) (HttpClient.Response Bytes)
171
171
}
172
172
| CompilerInstalled (Result FileSystem.Error Path)
173
- | CompilerInitialized { quiet : Bool, backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes }
173
+ | CompilerInitialized { headless : Bool, backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes }
174
174
| CompilerRan Int
175
175
| CompiledForRun { path : Path, exitCode : Int }
176
- | RunStarted Process.Id
176
+ | RunStarted { processId : Process.Id, streams : Maybe ChildProcess.StreamIO }
177
177
| RunExited Int
178
178
| RedirectTerminalIO
179
179
(Result
@@ -257,19 +257,29 @@ update msg model =
257
257
CompilerInstalled (Ok compilerPath) ->
258
258
parseUserArgs model compilerPath
259
259
260
- CompilerInitialized { backendStreams, encodedCommand, quiet } ->
260
+ CompilerInitialized { backendStreams, encodedCommand, headless } ->
261
261
Cmd.batch
262
- [ Stream.write encodedCommand backendStreams.input
263
- |> Task.map (\_ -> { source = model.stdin, target = backendStreams.input })
264
- |> Task.mapError
265
- (\err ->
266
- { error = err
267
- , source = model.stdin
268
- , target = backendStreams.input
269
- }
270
- )
271
- |> Task.attempt RedirectTerminalIO
272
- , if quiet then
262
+ [ if headless then
263
+ Stream.write encodedCommand backendStreams.input
264
+ |> Task.map (\_ -> {})
265
+ |> Task.onError
266
+ (\e ->
267
+ Stream.Log.line model.stderr (Stream.errorToString e)
268
+ |> Task.andThen (\_ -> Node.exitWithCode 1)
269
+ )
270
+ |> Task.execute
271
+ else
272
+ Stream.write encodedCommand backendStreams.input
273
+ |> Task.map (\_ -> { source = model.stdin, target = backendStreams.input })
274
+ |> Task.mapError
275
+ (\err ->
276
+ { error = err
277
+ , source = model.stdin
278
+ , target = backendStreams.input
279
+ }
280
+ )
281
+ |> Task.attempt RedirectTerminalIO
282
+ , if headless then
273
283
Cmd.none
274
284
else
275
285
Task.succeed { source = backendStreams.output, target = model.stdout }
@@ -288,7 +298,7 @@ update msg model =
288
298
, fsPermission = model.fsPermission
289
299
, pathToString = model.pathToString
290
300
, path = path
291
- , onInit = \{ processId } -> RunStarted processId
301
+ , onInit = RunStarted
292
302
, onExit = RunExited
293
303
}
294
304
|> Task.onError
@@ -391,7 +401,7 @@ parseUserArgs model compilerPath =
391
401
Just streams ->
392
402
CompilerInitialized
393
403
{ backendStreams = streams
394
- , quiet = False
404
+ , headless = False
395
405
, encodedCommand =
396
406
Compiler.Backend.encodeCommand
397
407
{ interactiveSession = model.interactive
@@ -544,7 +554,7 @@ parseUserArgs model compilerPath =
544
554
CompilerInitialized
545
555
{ backendStreams = streams
546
556
, encodedCommand = encodedCommand
547
- , quiet = True
557
+ , headless = True
548
558
}
549
559
)
550
560
, onCompiled =
0 commit comments