| 6 | export function spawn(cmd: string, args: string[], opts?: Process.Options): Child |
| 7 | export function spawn(cmd: string, opts?: Process.Options): Child |
| 8 | export function spawn(cmd: string, argsOrOpts?: string[] | Process.Options, opts?: Process.Options) { |
| 9 | const args = Array.isArray(argsOrOpts) ? [...argsOrOpts] : [] |
| 10 | const cfg = Array.isArray(argsOrOpts) ? opts : argsOrOpts |
| 11 | const proc = Process.spawn([cmd, ...args], { |
| 12 | ...cfg, |
| 13 | stdin: "pipe", |
| 14 | stdout: "pipe", |
| 15 | stderr: "pipe", |
| 16 | }) as Child |
| 17 | |
| 18 | if (!proc.stdin || !proc.stdout || !proc.stderr) throw new Error("Process output not available") |
| 19 | |
| 20 | return proc |
| 21 | } |