MCPcopy Create free account
hub / github.com/anomalyco/opencode / spawn

Function spawn

packages/core/src/cross-spawn-spawner.ts:267–290  ·  view source on GitHub ↗
(command: ChildProcess.StandardCommand, opts: NodeChildProcess.SpawnOptions)

Source from the content-addressed store, hash-verified

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,

Callers 1

Calls 5

resumeFunction · 0.85
toPlatformErrorFunction · 0.85
onMethod · 0.80
syncMethod · 0.80
callbackMethod · 0.45

Tested by

no test coverage detected