@@ -152,14 +152,14 @@ type Msg
152152 }
153153 | CompilerDownloaded
154154 { localPath : Path
155- , downloadResult : Result ( HttpClient.Error Bytes) (HttpClient.Response Bytes)
155+ , downloadResult : Result HttpClient.Error (HttpClient.Response Bytes)
156156 }
157157 | CompilerInstalled (Result FileSystem.Error Path)
158158 | CompilerInitialized { quiet : Bool, backendStreams : ChildProcess.StreamIO, encodedCommand : Bytes }
159159 | CompilerRan Int
160160 | CompilerRanStatic { path : String, exitCode : Int }
161161 | CompiledForRun { path : String, exitCode : Int }
162- | RunStarted { processId : Process.Id, streams : Maybe ChildProcess.StreamIO }
162+ | RunStarted { processId : Process.Id, streams : ChildProcess.StreamIO }
163163 | RunExited Int
164164
165165
@@ -268,15 +268,13 @@ update msg model =
268268
269269 CompilerRan exitCode ->
270270 Node.exitWithCode exitCode
271- |> Task.execute
272271
273272 CompilerRanStatic { path, exitCode } ->
274273 if exitCode == 0 then
275274 completeStaticBuild path
276275
277276 else
278277 Node.exitWithCode exitCode
279- |> Task.execute
280278
281279 CompiledForRun { path, exitCode } ->
282280 if exitCode == 0 then
@@ -289,14 +287,12 @@ update msg model =
289287
290288 else
291289 Node.exitWithCode exitCode
292- |> Task.execute
293290
294291 RunStarted _ ->
295292 Cmd.none
296293
297294 RunExited exitCode ->
298295 Node.exitWithCode exitCode
299- |> Task.execute
300296 }
301297
302298
@@ -343,23 +339,18 @@ parseUserArgs model compilerPath =
343339
344340 CLI.Parser.Success parsedCommand ->
345341 let
346- initWithCommand backendCommand cpOpts =
347- when cpOpts.streams is
348- Nothing ->
349- -- TODO: error handling
350- Debug.todo "no stream for child process"
351-
352- Just streams ->
353- CompilerInitialized
354- { backendStreams = streams
355- , quiet = False
356- , encodedCommand =
357- Compiler.Backend.encodeCommand
358- { interactiveSession = model.interactive
359- , pathToString = model.pathToString
360- }
361- backendCommand
362- }
342+ initWithCommand backendCommand =
343+ ChildProcess.External <| \cpOpts ->
344+ CompilerInitialized
345+ { backendStreams = cpOpts.streams
346+ , quiet = False
347+ , encodedCommand =
348+ Compiler.Backend.encodeCommand
349+ { interactiveSession = model.interactive
350+ , pathToString = model.pathToString
351+ }
352+ backendCommand
353+ }
363354 in
364355 when parsedCommand is
365356 CliParser.Init flags ->
@@ -398,7 +389,7 @@ parseUserArgs model compilerPath =
398389 { useColor = model.useColor
399390 , compilerPath = compilerPath
400391 , pathToString = model.pathToString
401- , onInit =
392+ , connection =
402393 initWithCommand <|
403394 Compiler.Backend.Repl
404395 { interpreter = flags.interpreter
@@ -439,7 +430,7 @@ parseUserArgs model compilerPath =
439430 { useColor = model.useColor
440431 , compilerPath = compilerPath
441432 , pathToString = model.pathToString
442- , onInit = initWithCommand <|
433+ , connection = initWithCommand <|
443434 Compiler.Backend.Make
444435 { optimize = flags.optimize
445436 , sourcemaps = flags.sourcemaps
@@ -485,7 +476,7 @@ parseUserArgs model compilerPath =
485476 { useColor = model.useColor
486477 , compilerPath = compilerPath
487478 , pathToString = model.pathToString
488- , onInit = initWithCommand <|
479+ , connection = initWithCommand <|
489480 Compiler.Backend.Make
490481 { optimize = True
491482 , sourcemaps = False
@@ -524,16 +515,11 @@ parseUserArgs model compilerPath =
524515 , moduleName = moduleName
525516 , onBackendInitialized =
526517 (\{ backendStreams, encodedCommand } ->
527- when backendStreams is
528- Nothing ->
529- Debug.todo "no backend streams"
530-
531- Just streams ->
532- CompilerInitialized
533- { backendStreams = streams
534- , encodedCommand = encodedCommand
535- , quiet = True
536- }
518+ CompilerInitialized
519+ { backendStreams = backendStreams
520+ , encodedCommand = encodedCommand
521+ , quiet = True
522+ }
537523 )
538524 , onCompiled =
539525 (\outputPath exitCode ->
@@ -575,7 +561,7 @@ parseUserArgs model compilerPath =
575561 { useColor = model.useColor
576562 , compilerPath = compilerPath
577563 , pathToString = model.pathToString
578- , onInit =
564+ , connection =
579565 initWithCommand <|
580566 Compiler.Backend.Docs
581567 { output = flags.output
@@ -762,7 +748,7 @@ parseUserArgs model compilerPath =
762748 (\backendFlags ->
763749 Compiler.Backend.run
764750 model.cpPermission
765- { onInit =
751+ { connection =
766752 initWithCommand <|
767753 Compiler.Backend.PackageBump backendFlags
768754 , useColor = model.useColor
@@ -848,7 +834,7 @@ parseUserArgs model compilerPath =
848834 (\backendFlags ->
849835 Compiler.Backend.run
850836 model.cpPermission
851- { onInit =
837+ { connection =
852838 initWithCommand <|
853839 Compiler.Backend.PackageDiff backendFlags
854840 , useColor = model.useColor
0 commit comments