(
cmd: string,
args: string[],
options: ExecDetachedOptions = {},
)
| 326 | } |
| 327 | |
| 328 | export function runCmdDetachedMonitored( |
| 329 | cmd: string, |
| 330 | args: string[], |
| 331 | options: ExecDetachedOptions = {}, |
| 332 | ): ExecDetachedProcess { |
| 333 | const executable = normalizeExecutableCommand(cmd); |
| 334 | const child = spawn(executable, args, { |
| 335 | cwd: options.cwd, |
| 336 | env: options.env, |
| 337 | stdio: options.stdio ?? 'ignore', |
| 338 | detached: true, |
| 339 | windowsHide: true, |
| 340 | shell: false, |
| 341 | }); |
| 342 | const pid = child.pid ?? 0; |
| 343 | const exited = new Promise<ExecDetachedExit>((resolve) => { |
| 344 | child.once('error', (err) => { |
| 345 | resolve({ pid, error: err.message }); |
| 346 | }); |
| 347 | child.once('exit', (code, signal) => { |
| 348 | resolve({ |
| 349 | pid, |
| 350 | ...(typeof code === 'number' ? { exitCode: code } : {}), |
| 351 | ...(signal ? { signal } : {}), |
| 352 | }); |
| 353 | }); |
| 354 | }); |
| 355 | child.unref(); |
| 356 | return { pid, exited }; |
| 357 | } |
| 358 | |
| 359 | export function runCmdBackground( |
| 360 | cmd: string, |
no test coverage detected