@@ -170,17 +170,14 @@ 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
180
- { error : Stream.Error
181
- , source : Stream.Readable Bytes
182
- , target : Stream.Writable Bytes
183
- }
180
+ Stream.Error
184
181
{ source : Stream.Readable Bytes
185
182
, target : Stream.Writable Bytes
186
183
}
@@ -257,19 +254,22 @@ update msg model =
257
254
CompilerInstalled (Ok compilerPath) ->
258
255
parseUserArgs model compilerPath
259
256
260
- CompilerInitialized { backendStreams, encodedCommand, quiet } ->
257
+ CompilerInitialized { backendStreams, encodedCommand, headless } ->
261
258
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
259
+ [ if headless then
260
+ Stream.write encodedCommand backendStreams.input
261
+ |> Task.map (\_ -> {})
262
+ |> Task.onError
263
+ (\e ->
264
+ Stream.Log.line model.stderr (Stream.errorToString e)
265
+ |> Task.andThen (\_ -> Node.exitWithCode 1)
266
+ )
267
+ |> Task.execute
268
+ else
269
+ Stream.write encodedCommand backendStreams.input
270
+ |> Task.map (\_ -> { source = model.stdin, target = backendStreams.input })
271
+ |> Task.attempt RedirectTerminalIO
272
+ , if headless then
273
273
Cmd.none
274
274
else
275
275
Task.succeed { source = backendStreams.output, target = model.stdout }
@@ -288,7 +288,7 @@ update msg model =
288
288
, fsPermission = model.fsPermission
289
289
, pathToString = model.pathToString
290
290
, path = path
291
- , onInit = \{ processId } -> RunStarted processId
291
+ , onInit = RunStarted
292
292
, onExit = RunExited
293
293
}
294
294
|> Task.onError
@@ -313,16 +313,9 @@ update msg model =
313
313
Stream.read streams.source
314
314
|> Task.andThen (\str -> Stream.write str streams.target)
315
315
|> Task.map (\_ -> streams)
316
- |> Task.mapError
317
- (\err ->
318
- { error = err
319
- , source = streams.source
320
- , target = streams.target
321
- }
322
- )
323
316
|> Task.attempt RedirectTerminalIO
324
317
325
- RedirectTerminalIO (Err { error, source, target } ) ->
318
+ RedirectTerminalIO (Err error) ->
326
319
when error is
327
320
Stream.Closed ->
328
321
Cmd.none
@@ -391,7 +384,7 @@ parseUserArgs model compilerPath =
391
384
Just streams ->
392
385
CompilerInitialized
393
386
{ backendStreams = streams
394
- , quiet = False
387
+ , headless = False
395
388
, encodedCommand =
396
389
Compiler.Backend.encodeCommand
397
390
{ interactiveSession = model.interactive
@@ -544,7 +537,7 @@ parseUserArgs model compilerPath =
544
537
CompilerInitialized
545
538
{ backendStreams = streams
546
539
, encodedCommand = encodedCommand
547
- , quiet = True
540
+ , headless = True
548
541
}
549
542
)
550
543
, onCompiled =
0 commit comments