UNPKG

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