@@ -170,10 +170,10 @@ type Msg
170170 , downloadResult : Result (HttpClient.Error Bytes) (HttpClient.Response Bytes)
171171 }
172172 | CompilerInstalled (Result FileSystem.Error Path)
173- | CompilerInitialized { quiet : Bool, backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes }
173+ | CompilerInitialized { headless : Bool, backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes }
174174 | CompilerRan Int
175175 | CompiledForRun { path : Path, exitCode : Int }
176- | RunStarted Process.Id
176+ | RunStarted { processId : Process.Id, streams : Maybe ChildProcess.StreamIO }
177177 | RunExited Int
178178 | RedirectTerminalIO
179179 (Result
@@ -257,19 +257,29 @@ update msg model =
257257 CompilerInstalled (Ok compilerPath) ->
258258 parseUserArgs model compilerPath
259259
260- CompilerInitialized { backendStreams, encodedCommand, quiet } ->
260+ CompilerInitialized { backendStreams, encodedCommand, headless } ->
261261 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
273283 Cmd.none
274284 else
275285 Task.succeed { source = backendStreams.output, target = model.stdout }
@@ -288,7 +298,7 @@ update msg model =
288298 , fsPermission = model.fsPermission
289299 , pathToString = model.pathToString
290300 , path = path
291- , onInit = \{ processId } -> RunStarted processId
301+ , onInit = RunStarted
292302 , onExit = RunExited
293303 }
294304 |> Task.onError
@@ -391,7 +401,7 @@ parseUserArgs model compilerPath =
391401 Just streams ->
392402 CompilerInitialized
393403 { backendStreams = streams
394- , quiet = False
404+ , headless = False
395405 , encodedCommand =
396406 Compiler.Backend.encodeCommand
397407 { interactiveSession = model.interactive
@@ -544,7 +554,7 @@ parseUserArgs model compilerPath =
544554 CompilerInitialized
545555 { backendStreams = streams
546556 , encodedCommand = encodedCommand
547- , quiet = True
557+ , headless = True
548558 }
549559 )
550560 , onCompiled =
0 commit comments