UNPKG

26 kBTypeScriptView Raw
1declare module 'child_process' {
2 import { BaseEncodingOptions } from 'fs';
3 import { EventEmitter, Abortable } from 'events';
4 import * as net from 'net';
5 import { Writable, Readable, Stream, Pipe } from 'stream';
6
7 type Serializable = string | object | number | boolean | bigint;
8 type SendHandle = net.Socket | net.Server;
9
10 interface ChildProcess extends EventEmitter {
11 stdin: Writable | null;
12 stdout: Readable | null;
13 stderr: Readable | null;
14 readonly channel?: Pipe | null;
15 readonly stdio: [
16 Writable | null, // stdin
17 Readable | null, // stdout
18 Readable | null, // stderr
19 Readable | Writable | null | undefined, // extra
20 Readable | Writable | null | undefined // extra
21 ];
22 readonly killed: boolean;
23 readonly pid?: number;
24 readonly connected: boolean;
25 readonly exitCode: number | null;
26 readonly signalCode: NodeJS.Signals | null;
27 readonly spawnargs: string[];
28 readonly spawnfile: string;
29 kill(signal?: NodeJS.Signals | number): boolean;
30 send(message: Serializable, callback?: (error: Error | null) => void): boolean;
31 send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
32 send(message: Serializable, sendHandle?: SendHandle, options?: MessageOptions, callback?: (error: Error | null) => void): boolean;
33 disconnect(): void;
34 unref(): void;
35 ref(): void;
36
37 /**
38 * events.EventEmitter
39 * 1. close
40 * 2. disconnect
41 * 3. error
42 * 4. exit
43 * 5. message
44 * 6. spawn
45 */
46
47 addListener(event: string, listener: (...args: any[]) => void): this;
48 addListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
49 addListener(event: "disconnect", listener: () => void): this;
50 addListener(event: "error", listener: (err: Error) => void): this;
51 addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
52 addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
53 addListener(event: "spawn", listener: () => void): this;
54
55 emit(event: string | symbol, ...args: any[]): boolean;
56 emit(event: "close", code: number | null, signal: NodeJS.Signals | null): boolean;
57 emit(event: "disconnect"): boolean;
58 emit(event: "error", err: Error): boolean;
59 emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean;
60 emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean;
61 emit(event: "spawn", listener: () => void): boolean;
62
63 on(event: string, listener: (...args: any[]) => void): this;
64 on(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
65 on(event: "disconnect", listener: () => void): this;
66 on(event: "error", listener: (err: Error) => void): this;
67 on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
68 on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
69 on(event: "spawn", listener: () => void): this;
70
71 once(event: string, listener: (...args: any[]) => void): this;
72 once(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
73 once(event: "disconnect", listener: () => void): this;
74 once(event: "error", listener: (err: Error) => void): this;
75 once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
76 once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
77 once(event: "spawn", listener: () => void): this;
78
79 prependListener(event: string, listener: (...args: any[]) => void): this;
80 prependListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
81 prependListener(event: "disconnect", listener: () => void): this;
82 prependListener(event: "error", listener: (err: Error) => void): this;
83 prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
84 prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
85 prependListener(event: "spawn", listener: () => void): this;
86
87 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
88 prependOnceListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
89 prependOnceListener(event: "disconnect", listener: () => void): this;
90 prependOnceListener(event: "error", listener: (err: Error) => void): this;
91 prependOnceListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
92 prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
93 prependOnceListener(event: "spawn", listener: () => void): this;
94 }
95
96 // return this object when stdio option is undefined or not specified
97 interface ChildProcessWithoutNullStreams extends ChildProcess {
98 stdin: Writable;
99 stdout: Readable;
100 stderr: Readable;
101 readonly stdio: [
102 Writable, // stdin
103 Readable, // stdout
104 Readable, // stderr
105 Readable | Writable | null | undefined, // extra, no modification
106 Readable | Writable | null | undefined // extra, no modification
107 ];
108 }
109
110 // return this object when stdio option is a tuple of 3
111 interface ChildProcessByStdio<
112 I extends null | Writable,
113 O extends null | Readable,
114 E extends null | Readable,
115 > extends ChildProcess {
116 stdin: I;
117 stdout: O;
118 stderr: E;
119 readonly stdio: [
120 I,
121 O,
122 E,
123 Readable | Writable | null | undefined, // extra, no modification
124 Readable | Writable | null | undefined // extra, no modification
125 ];
126 }
127
128 interface MessageOptions {
129 keepOpen?: boolean;
130 }
131
132 type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
133
134 type StdioOptions = IOType | Array<(IOType | "ipc" | Stream | number | null | undefined)>;
135
136 type SerializationType = 'json' | 'advanced';
137
138 interface MessagingOptions extends Abortable {
139 /**
140 * Specify the kind of serialization used for sending messages between processes.
141 * @default 'json'
142 */
143 serialization?: SerializationType;
144
145 /**
146 * The signal value to be used when the spawned process will be killed by the abort signal.
147 * @default 'SIGTERM'
148 */
149 killSignal?: NodeJS.Signals | number;
150
151 /**
152 * In milliseconds the maximum amount of time the process is allowed to run.
153 */
154 timeout?: number;
155 }
156
157 interface ProcessEnvOptions {
158 uid?: number;
159 gid?: number;
160 cwd?: string;
161 env?: NodeJS.ProcessEnv;
162 }
163
164 interface CommonOptions extends ProcessEnvOptions {
165 /**
166 * @default true
167 */
168 windowsHide?: boolean;
169 /**
170 * @default 0
171 */
172 timeout?: number;
173 }
174
175 interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
176 argv0?: string;
177 stdio?: StdioOptions;
178 shell?: boolean | string;
179 windowsVerbatimArguments?: boolean;
180 }
181
182 interface SpawnOptions extends CommonSpawnOptions {
183 detached?: boolean;
184 }
185
186 interface SpawnOptionsWithoutStdio extends SpawnOptions {
187 stdio?: StdioPipeNamed | StdioPipe[];
188 }
189
190 type StdioNull = 'inherit' | 'ignore' | Stream;
191 type StdioPipeNamed = 'pipe' | 'overlapped';
192 type StdioPipe = undefined | null | StdioPipeNamed;
193
194 interface SpawnOptionsWithStdioTuple<
195 Stdin extends StdioNull | StdioPipe,
196 Stdout extends StdioNull | StdioPipe,
197 Stderr extends StdioNull | StdioPipe,
198 > extends SpawnOptions {
199 stdio: [Stdin, Stdout, Stderr];
200 }
201
202 // overloads of spawn without 'args'
203 function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
204
205 function spawn(
206 command: string,
207 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
208 ): ChildProcessByStdio<Writable, Readable, Readable>;
209 function spawn(
210 command: string,
211 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
212 ): ChildProcessByStdio<Writable, Readable, null>;
213 function spawn(
214 command: string,
215 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
216 ): ChildProcessByStdio<Writable, null, Readable>;
217 function spawn(
218 command: string,
219 options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
220 ): ChildProcessByStdio<null, Readable, Readable>;
221 function spawn(
222 command: string,
223 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
224 ): ChildProcessByStdio<Writable, null, null>;
225 function spawn(
226 command: string,
227 options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
228 ): ChildProcessByStdio<null, Readable, null>;
229 function spawn(
230 command: string,
231 options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
232 ): ChildProcessByStdio<null, null, Readable>;
233 function spawn(
234 command: string,
235 options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
236 ): ChildProcessByStdio<null, null, null>;
237
238 function spawn(command: string, options: SpawnOptions): ChildProcess;
239
240 // overloads of spawn with 'args'
241 function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
242
243 function spawn(
244 command: string,
245 args: ReadonlyArray<string>,
246 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
247 ): ChildProcessByStdio<Writable, Readable, Readable>;
248 function spawn(
249 command: string,
250 args: ReadonlyArray<string>,
251 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
252 ): ChildProcessByStdio<Writable, Readable, null>;
253 function spawn(
254 command: string,
255 args: ReadonlyArray<string>,
256 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
257 ): ChildProcessByStdio<Writable, null, Readable>;
258 function spawn(
259 command: string,
260 args: ReadonlyArray<string>,
261 options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
262 ): ChildProcessByStdio<null, Readable, Readable>;
263 function spawn(
264 command: string,
265 args: ReadonlyArray<string>,
266 options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
267 ): ChildProcessByStdio<Writable, null, null>;
268 function spawn(
269 command: string,
270 args: ReadonlyArray<string>,
271 options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
272 ): ChildProcessByStdio<null, Readable, null>;
273 function spawn(
274 command: string,
275 args: ReadonlyArray<string>,
276 options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
277 ): ChildProcessByStdio<null, null, Readable>;
278 function spawn(
279 command: string,
280 args: ReadonlyArray<string>,
281 options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
282 ): ChildProcessByStdio<null, null, null>;
283
284 function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptions): ChildProcess;
285
286 interface ExecOptions extends CommonOptions {
287 shell?: string;
288 maxBuffer?: number;
289 killSignal?: NodeJS.Signals | number;
290 }
291
292 interface ExecOptionsWithStringEncoding extends ExecOptions {
293 encoding: BufferEncoding;
294 }
295
296 interface ExecOptionsWithBufferEncoding extends ExecOptions {
297 encoding: BufferEncoding | null; // specify `null`.
298 }
299
300 interface ExecException extends Error {
301 cmd?: string;
302 killed?: boolean;
303 code?: number;
304 signal?: NodeJS.Signals;
305 }
306
307 // no `options` definitely means stdout/stderr are `string`.
308 function exec(command: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
309
310 // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
311 function exec(command: string, options: { encoding: "buffer" | null } & ExecOptions, callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
312
313 // `options` with well known `encoding` means stdout/stderr are definitely `string`.
314 function exec(command: string, options: { encoding: BufferEncoding } & ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
315
316 // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
317 // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
318 function exec(
319 command: string,
320 options: { encoding: BufferEncoding } & ExecOptions,
321 callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
322 ): ChildProcess;
323
324 // `options` without an `encoding` means stdout/stderr are definitely `string`.
325 function exec(command: string, options: ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
326
327 // fallback if nothing else matches. Worst case is always `string | Buffer`.
328 function exec(
329 command: string,
330 options: (BaseEncodingOptions & ExecOptions) | undefined | null,
331 callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
332 ): ChildProcess;
333
334 interface PromiseWithChild<T> extends Promise<T> {
335 child: ChildProcess;
336 }
337
338 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
339 namespace exec {
340 function __promisify__(command: string): PromiseWithChild<{ stdout: string, stderr: string }>;
341 function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
342 function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
343 function __promisify__(command: string, options: ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
344 function __promisify__(command: string, options?: (BaseEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
345 }
346
347 interface ExecFileOptions extends CommonOptions, Abortable {
348 maxBuffer?: number;
349 killSignal?: NodeJS.Signals | number;
350 windowsVerbatimArguments?: boolean;
351 shell?: boolean | string;
352 signal?: AbortSignal;
353 }
354 interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
355 encoding: BufferEncoding;
356 }
357 interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
358 encoding: 'buffer' | null;
359 }
360 interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
361 encoding: BufferEncoding;
362 }
363 type ExecFileException = ExecException & NodeJS.ErrnoException;
364
365 function execFile(file: string): ChildProcess;
366 function execFile(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
367 function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
368 function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
369
370 // no `options` definitely means stdout/stderr are `string`.
371 function execFile(file: string, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
372 function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
373
374 // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
375 function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
376 function execFile(
377 file: string,
378 args: ReadonlyArray<string> | undefined | null,
379 options: ExecFileOptionsWithBufferEncoding,
380 callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
381 ): ChildProcess;
382
383 // `options` with well known `encoding` means stdout/stderr are definitely `string`.
384 function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
385 function execFile(
386 file: string,
387 args: ReadonlyArray<string> | undefined | null,
388 options: ExecFileOptionsWithStringEncoding,
389 callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
390 ): ChildProcess;
391
392 // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
393 // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
394 function execFile(
395 file: string,
396 options: ExecFileOptionsWithOtherEncoding,
397 callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
398 ): ChildProcess;
399 function execFile(
400 file: string,
401 args: ReadonlyArray<string> | undefined | null,
402 options: ExecFileOptionsWithOtherEncoding,
403 callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
404 ): ChildProcess;
405
406 // `options` without an `encoding` means stdout/stderr are definitely `string`.
407 function execFile(file: string, options: ExecFileOptions, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
408 function execFile(
409 file: string,
410 args: ReadonlyArray<string> | undefined | null,
411 options: ExecFileOptions,
412 callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
413 ): ChildProcess;
414
415 // fallback if nothing else matches. Worst case is always `string | Buffer`.
416 function execFile(
417 file: string,
418 options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
419 callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
420 ): ChildProcess;
421 function execFile(
422 file: string,
423 args: ReadonlyArray<string> | undefined | null,
424 options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
425 callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
426 ): ChildProcess;
427
428 // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
429 namespace execFile {
430 function __promisify__(file: string): PromiseWithChild<{ stdout: string, stderr: string }>;
431 function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null): PromiseWithChild<{ stdout: string, stderr: string }>;
432 function __promisify__(file: string, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
433 function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
434 function __promisify__(file: string, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
435 function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
436 function __promisify__(file: string, options: ExecFileOptionsWithOtherEncoding): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
437 function __promisify__(
438 file: string,
439 args: ReadonlyArray<string> | undefined | null,
440 options: ExecFileOptionsWithOtherEncoding,
441 ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
442 function __promisify__(file: string, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
443 function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
444 function __promisify__(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
445 function __promisify__(
446 file: string,
447 args: ReadonlyArray<string> | undefined | null,
448 options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
449 ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
450 }
451
452 interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
453 execPath?: string;
454 execArgv?: string[];
455 silent?: boolean;
456 stdio?: StdioOptions;
457 detached?: boolean;
458 windowsVerbatimArguments?: boolean;
459 }
460 function fork(modulePath: string, options?: ForkOptions): ChildProcess;
461 function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
462
463 interface SpawnSyncOptions extends CommonSpawnOptions {
464 input?: string | NodeJS.ArrayBufferView;
465 maxBuffer?: number;
466 encoding?: BufferEncoding | 'buffer' | null;
467 }
468 interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
469 encoding: BufferEncoding;
470 }
471 interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
472 encoding?: 'buffer' | null;
473 }
474 interface SpawnSyncReturns<T> {
475 pid: number;
476 output: string[];
477 stdout: T;
478 stderr: T;
479 status: number | null;
480 signal: NodeJS.Signals | null;
481 error?: Error;
482 }
483 function spawnSync(command: string): SpawnSyncReturns<Buffer>;
484 function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
485 function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
486 function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
487 function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
488 function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
489 function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
490
491 interface CommonExecOptions extends ProcessEnvOptions {
492 input?: string | NodeJS.ArrayBufferView;
493 stdio?: StdioOptions;
494 killSignal?: NodeJS.Signals | number;
495 maxBuffer?: number;
496 encoding?: BufferEncoding | 'buffer' | null;
497 }
498
499 interface ExecSyncOptions extends CommonExecOptions {
500 shell?: string;
501 }
502 interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
503 encoding: BufferEncoding;
504 }
505 interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
506 encoding?: 'buffer' | null;
507 }
508 function execSync(command: string): Buffer;
509 function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
510 function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
511 function execSync(command: string, options?: ExecSyncOptions): Buffer;
512
513 interface ExecFileSyncOptions extends CommonExecOptions {
514 shell?: boolean | string;
515 }
516 interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
517 encoding: BufferEncoding;
518 }
519 interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
520 encoding: BufferEncoding; // specify `null`.
521 }
522 function execFileSync(command: string): Buffer;
523 function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
524 function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
525 function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
526 function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithStringEncoding): string;
527 function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
528 function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): Buffer;
529}