1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import {
|
10 | ChildProcess,
|
11 | ExecFileOptionsWithBufferEncoding, ExecFileOptionsWithOtherEncoding,
|
12 | ExecFileOptionsWithStringEncoding,
|
13 | ExecOptions,
|
14 | ForkOptions,
|
15 | SpawnOptions
|
16 | } from 'child_process';
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export interface PromiseResult<Enc extends string|Buffer> {
|
23 | childProcess: ChildProcess;
|
24 | stdout: Enc;
|
25 | stderr: Enc;
|
26 | }
|
27 |
|
28 | export interface SpawnPromiseResult extends PromiseResult<string> {
|
29 | code: number;
|
30 | }
|
31 |
|
32 | export interface ChildProcessPromise<T> extends Promise<T> {
|
33 | childProcess: ChildProcess;
|
34 | }
|
35 |
|
36 | export interface Options {
|
37 | |
38 |
|
39 |
|
40 |
|
41 | capture?: []|['stdout'|'stderr']|['stdout', 'stderr']|['stderr', 'stdout'] | undefined;
|
42 | |
43 |
|
44 |
|
45 |
|
46 | successfulExitCodes?: number[] | undefined;
|
47 | }
|
48 |
|
49 | export function exec(
|
50 | command: Readonly<string>,
|
51 | options: Readonly<Options & { encoding: "buffer" | null } & ExecOptions>
|
52 | ): ChildProcessPromise<PromiseResult<Buffer>>;
|
53 | export function exec(
|
54 | command: Readonly<string>,
|
55 | options: Readonly<Options & { encoding?: BufferEncoding | undefined } & ExecOptions>
|
56 | ): ChildProcessPromise<PromiseResult<string>>;
|
57 | export function exec(
|
58 | command: Readonly<string>,
|
59 | options: Readonly<Options & { encoding?: string | undefined } & ExecOptions>
|
60 | ): ChildProcessPromise<PromiseResult<string | Buffer>>;
|
61 | export function exec(
|
62 | command: Readonly<string>,
|
63 | options?: Readonly<Options & ExecOptions>
|
64 | ): ChildProcessPromise<PromiseResult<string>>;
|
65 |
|
66 | export function execFile(
|
67 | file: Readonly<string>,
|
68 | options: Readonly<Options & ExecFileOptionsWithBufferEncoding>
|
69 | ): ChildProcessPromise<PromiseResult<Buffer>>;
|
70 | export function execFile(
|
71 | file: Readonly<string>,
|
72 | args: ReadonlyArray<string> | null,
|
73 | options: Readonly<Options & ExecFileOptionsWithBufferEncoding>
|
74 | ): ChildProcessPromise<PromiseResult<Buffer>>;
|
75 | export function execFile(
|
76 | file: Readonly<string>,
|
77 | options: Readonly<Options & ExecFileOptionsWithStringEncoding>
|
78 | ): ChildProcessPromise<PromiseResult<string>>;
|
79 | export function execFile(
|
80 | file: Readonly<string>,
|
81 | options: Readonly<Options & ExecFileOptionsWithOtherEncoding>
|
82 | ): ChildProcessPromise<PromiseResult<string | Buffer>>;
|
83 | export function execFile(
|
84 | file: Readonly<string>,
|
85 | args: ReadonlyArray<string> | null,
|
86 | options: Readonly<Options & ExecFileOptionsWithOtherEncoding>
|
87 | ): ChildProcessPromise<PromiseResult<string | Buffer>>;
|
88 | export function execFile(
|
89 | file: Readonly<string>,
|
90 | args?: ReadonlyArray<string> | null,
|
91 | options?: Readonly<Options & ExecFileOptionsWithStringEncoding>
|
92 | ): ChildProcessPromise<PromiseResult<string>>;
|
93 |
|
94 | export function spawn(
|
95 | command: Readonly<string>,
|
96 | args?: ReadonlyArray<string> | null,
|
97 | options?: Readonly<Options & SpawnOptions>
|
98 | ): ChildProcessPromise<SpawnPromiseResult>;
|
99 |
|
100 | export function fork(
|
101 | modulePath: string,
|
102 | args?: ReadonlyArray<string>,
|
103 | options?: Readonly<Options & ForkOptions>
|
104 | ): ChildProcessPromise<SpawnPromiseResult>;
|