forked from microsoft/vscode-python-environments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchildProcess.apis.ts
More file actions
28 lines (24 loc) · 948 Bytes
/
childProcess.apis.ts
File metadata and controls
28 lines (24 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as cp from 'child_process';
/**
* Spawns a new process using the specified command and arguments.
* This function abstracts cp.spawn to make it easier to mock in tests.
*
* When stdio: 'pipe' is used, returns ChildProcessWithoutNullStreams.
* Otherwise returns the standard ChildProcess.
*/
// Overload for stdio: 'pipe' - guarantees non-null streams
export function spawnProcess(
command: string,
args: string[],
options: cp.SpawnOptions & { stdio: 'pipe' },
): cp.ChildProcessWithoutNullStreams;
// Overload for general case
export function spawnProcess(command: string, args: string[], options?: cp.SpawnOptions): cp.ChildProcess;
// Implementation - delegates to cp.spawn to preserve its typing magic
export function spawnProcess(
command: string,
args: string[],
options?: cp.SpawnOptions,
): cp.ChildProcess | cp.ChildProcessWithoutNullStreams {
return cp.spawn(command, args, options ?? {});
}