* Spawn a terminal detached so the handler process can exit without * waiting for the terminal to close. Resolves false on spawn failure * (ENOENT, EACCES) rather than crashing.
(
command: string,
args: string[],
opts: { cwd?: string; windowsVerbatimArguments?: boolean } = {},
)
| 474 | * (ENOENT, EACCES) rather than crashing. |
| 475 | */ |
| 476 | function spawnDetached( |
| 477 | command: string, |
| 478 | args: string[], |
| 479 | opts: { cwd?: string; windowsVerbatimArguments?: boolean } = {}, |
| 480 | ): Promise<boolean> { |
| 481 | return new Promise<boolean>(resolve => { |
| 482 | const child = spawn(command, args, { |
| 483 | detached: true, |
| 484 | stdio: 'ignore', |
| 485 | cwd: opts.cwd, |
| 486 | windowsVerbatimArguments: opts.windowsVerbatimArguments, |
| 487 | }) |
| 488 | child.once('error', err => { |
| 489 | logForDebugging(`Failed to spawn ${command}: ${err.message}`, { |
| 490 | level: 'error', |
| 491 | }) |
| 492 | void resolve(false) |
| 493 | }) |
| 494 | child.once('spawn', () => { |
| 495 | child.unref() |
| 496 | void resolve(true) |
| 497 | }) |
| 498 | }) |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * Build a single-quoted POSIX shell command string. ONLY used by the |
no test coverage detected