(command: ChildProcess.StandardCommand, opts: NodeChildProcess.SpawnOptions)
| 265 | } |
| 266 | |
| 267 | const spawn = (command: ChildProcess.StandardCommand, opts: NodeChildProcess.SpawnOptions) => |
| 268 | Effect.callback<readonly [NodeChildProcess.ChildProcess, ExitSignal], PlatformError.PlatformError>((resume) => { |
| 269 | const signal = Deferred.makeUnsafe<readonly [code: number | null, signal: NodeJS.Signals | null]>() |
| 270 | const proc = launch(command.command, command.args, opts) |
| 271 | let end = false |
| 272 | let exit: readonly [code: number | null, signal: NodeJS.Signals | null] | undefined |
| 273 | proc.on("error", (err) => { |
| 274 | resume(Effect.fail(toPlatformError("spawn", err, command))) |
| 275 | }) |
| 276 | proc.on("exit", (...args) => { |
| 277 | exit = args |
| 278 | }) |
| 279 | proc.on("close", (...args) => { |
| 280 | if (end) return |
| 281 | end = true |
| 282 | Deferred.doneUnsafe(signal, Exit.succeed(exit ?? args)) |
| 283 | }) |
| 284 | proc.on("spawn", () => { |
| 285 | resume(Effect.succeed([proc, signal])) |
| 286 | }) |
| 287 | return Effect.sync(() => { |
| 288 | proc.kill("SIGTERM") |
| 289 | }) |
| 290 | }) |
| 291 | |
| 292 | const killGroup = ( |
| 293 | command: ChildProcess.StandardCommand, |
no test coverage detected