Projekt

Obecné

Profil

Stáhnout (24 KB) Statistiky
| Větev: | Revize:
1
declare module "child_process" {
2
    import * as events from "events";
3
    import * as net from "net";
4
    import { Writable, Readable, Stream, Pipe } from "stream";
5

    
6
    type Serializable = string | object | number | boolean;
7
    type SendHandle = net.Socket | net.Server;
8

    
9
    interface ChildProcess extends events.EventEmitter {
10
        stdin: Writable | null;
11
        stdout: Readable | null;
12
        stderr: Readable | null;
13
        readonly channel?: Pipe | null;
14
        readonly stdio: [
15
            Writable | null, // stdin
16
            Readable | null, // stdout
17
            Readable | null, // stderr
18
            Readable | Writable | null | undefined, // extra
19
            Readable | Writable | null | undefined // extra
20
        ];
21
        readonly killed: boolean;
22
        readonly pid: number;
23
        readonly connected: boolean;
24
        kill(signal?: NodeJS.Signals | number): boolean;
25
        send(message: Serializable, callback?: (error: Error | null) => void): boolean;
26
        send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
27
        send(message: Serializable, sendHandle?: SendHandle, options?: MessageOptions, callback?: (error: Error | null) => void): boolean;
28
        disconnect(): void;
29
        unref(): void;
30
        ref(): void;
31

    
32
        /**
33
         * events.EventEmitter
34
         * 1. close
35
         * 2. disconnect
36
         * 3. error
37
         * 4. exit
38
         * 5. message
39
         */
40

    
41
        addListener(event: string, listener: (...args: any[]) => void): this;
42
        addListener(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
43
        addListener(event: "disconnect", listener: () => void): this;
44
        addListener(event: "error", listener: (err: Error) => void): this;
45
        addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
46
        addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
47

    
48
        emit(event: string | symbol, ...args: any[]): boolean;
49
        emit(event: "close", code: number, signal: NodeJS.Signals): boolean;
50
        emit(event: "disconnect"): boolean;
51
        emit(event: "error", err: Error): boolean;
52
        emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean;
53
        emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean;
54

    
55
        on(event: string, listener: (...args: any[]) => void): this;
56
        on(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
57
        on(event: "disconnect", listener: () => void): this;
58
        on(event: "error", listener: (err: Error) => void): this;
59
        on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
60
        on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
61

    
62
        once(event: string, listener: (...args: any[]) => void): this;
63
        once(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
64
        once(event: "disconnect", listener: () => void): this;
65
        once(event: "error", listener: (err: Error) => void): this;
66
        once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
67
        once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
68

    
69
        prependListener(event: string, listener: (...args: any[]) => void): this;
70
        prependListener(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
71
        prependListener(event: "disconnect", listener: () => void): this;
72
        prependListener(event: "error", listener: (err: Error) => void): this;
73
        prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
74
        prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
75

    
76
        prependOnceListener(event: string, listener: (...args: any[]) => void): this;
77
        prependOnceListener(event: "close", listener: (code: number, signal: NodeJS.Signals) => void): this;
78
        prependOnceListener(event: "disconnect", listener: () => void): this;
79
        prependOnceListener(event: "error", listener: (err: Error) => void): this;
80
        prependOnceListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
81
        prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
82
    }
83

    
84
    // return this object when stdio option is undefined or not specified
85
    interface ChildProcessWithoutNullStreams extends ChildProcess {
86
        stdin: Writable;
87
        stdout: Readable;
88
        stderr: Readable;
89
        readonly stdio: [
90
            Writable, // stdin
91
            Readable, // stdout
92
            Readable, // stderr
93
            Readable | Writable | null | undefined, // extra, no modification
94
            Readable | Writable | null | undefined // extra, no modification
95
        ];
96
    }
97

    
98
    // return this object when stdio option is a tuple of 3
99
    interface ChildProcessByStdio<
100
        I extends null | Writable,
101
        O extends null | Readable,
102
        E extends null | Readable,
103
    > extends ChildProcess {
104
        stdin: I;
105
        stdout: O;
106
        stderr: E;
107
        readonly stdio: [
108
            I,
109
            O,
110
            E,
111
            Readable | Writable | null | undefined, // extra, no modification
112
            Readable | Writable | null | undefined // extra, no modification
113
        ];
114
    }
115

    
116
    interface MessageOptions {
117
        keepOpen?: boolean;
118
    }
119

    
120
    type StdioOptions = "pipe" | "ignore" | "inherit" | Array<("pipe" | "ipc" | "ignore" | "inherit" | Stream | number | null | undefined)>;
121

    
122
    type SerializationType = 'json' | 'advanced';
123

    
124
    interface MessagingOptions {
125
        /**
126
         * Specify the kind of serialization used for sending messages between processes.
127
         * @default 'json'
128
         */
129
        serialization?: SerializationType;
130
    }
131

    
132
    interface ProcessEnvOptions {
133
        uid?: number;
134
        gid?: number;
135
        cwd?: string;
136
        env?: NodeJS.ProcessEnv;
137
    }
138

    
139
    interface CommonOptions extends ProcessEnvOptions {
140
        /**
141
         * @default true
142
         */
143
        windowsHide?: boolean;
144
        /**
145
         * @default 0
146
         */
147
        timeout?: number;
148
    }
149

    
150
    interface CommonSpawnOptions extends CommonOptions, MessagingOptions {
151
        argv0?: string;
152
        stdio?: StdioOptions;
153
        shell?: boolean | string;
154
        windowsVerbatimArguments?: boolean;
155
    }
156

    
157
    interface SpawnOptions extends CommonSpawnOptions {
158
        detached?: boolean;
159
    }
160

    
161
    interface SpawnOptionsWithoutStdio extends SpawnOptions {
162
        stdio?: 'pipe' | Array<null | undefined | 'pipe'>;
163
    }
164

    
165
    type StdioNull = 'inherit' | 'ignore' | Stream;
166
    type StdioPipe = undefined | null | 'pipe';
167

    
168
    interface SpawnOptionsWithStdioTuple<
169
        Stdin extends StdioNull | StdioPipe,
170
        Stdout extends StdioNull | StdioPipe,
171
        Stderr extends StdioNull | StdioPipe,
172
    > extends SpawnOptions {
173
        stdio: [Stdin, Stdout, Stderr];
174
    }
175

    
176
    // overloads of spawn without 'args'
177
    function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
178

    
179
    function spawn(
180
        command: string,
181
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
182
    ): ChildProcessByStdio<Writable, Readable, Readable>;
183
    function spawn(
184
        command: string,
185
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
186
    ): ChildProcessByStdio<Writable, Readable, null>;
187
    function spawn(
188
        command: string,
189
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
190
    ): ChildProcessByStdio<Writable, null, Readable>;
191
    function spawn(
192
        command: string,
193
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
194
    ): ChildProcessByStdio<null, Readable, Readable>;
195
    function spawn(
196
        command: string,
197
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
198
    ): ChildProcessByStdio<Writable, null, null>;
199
    function spawn(
200
        command: string,
201
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
202
    ): ChildProcessByStdio<null, Readable, null>;
203
    function spawn(
204
        command: string,
205
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
206
    ): ChildProcessByStdio<null, null, Readable>;
207
    function spawn(
208
        command: string,
209
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
210
    ): ChildProcessByStdio<null, null, null>;
211

    
212
    function spawn(command: string, options: SpawnOptions): ChildProcess;
213

    
214
    // overloads of spawn with 'args'
215
    function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
216

    
217
    function spawn(
218
        command: string,
219
        args: ReadonlyArray<string>,
220
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
221
    ): ChildProcessByStdio<Writable, Readable, Readable>;
222
    function spawn(
223
        command: string,
224
        args: ReadonlyArray<string>,
225
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
226
    ): ChildProcessByStdio<Writable, Readable, null>;
227
    function spawn(
228
        command: string,
229
        args: ReadonlyArray<string>,
230
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
231
    ): ChildProcessByStdio<Writable, null, Readable>;
232
    function spawn(
233
        command: string,
234
        args: ReadonlyArray<string>,
235
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
236
    ): ChildProcessByStdio<null, Readable, Readable>;
237
    function spawn(
238
        command: string,
239
        args: ReadonlyArray<string>,
240
        options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
241
    ): ChildProcessByStdio<Writable, null, null>;
242
    function spawn(
243
        command: string,
244
        args: ReadonlyArray<string>,
245
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
246
    ): ChildProcessByStdio<null, Readable, null>;
247
    function spawn(
248
        command: string,
249
        args: ReadonlyArray<string>,
250
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
251
    ): ChildProcessByStdio<null, null, Readable>;
252
    function spawn(
253
        command: string,
254
        args: ReadonlyArray<string>,
255
        options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
256
    ): ChildProcessByStdio<null, null, null>;
257

    
258
    function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptions): ChildProcess;
259

    
260
    interface ExecOptions extends CommonOptions {
261
        shell?: string;
262
        maxBuffer?: number;
263
        killSignal?: NodeJS.Signals | number;
264
    }
265

    
266
    interface ExecOptionsWithStringEncoding extends ExecOptions {
267
        encoding: BufferEncoding;
268
    }
269

    
270
    interface ExecOptionsWithBufferEncoding extends ExecOptions {
271
        encoding: string | null; // specify `null`.
272
    }
273

    
274
    interface ExecException extends Error {
275
        cmd?: string;
276
        killed?: boolean;
277
        code?: number;
278
        signal?: NodeJS.Signals;
279
    }
280

    
281
    // no `options` definitely means stdout/stderr are `string`.
282
    function exec(command: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
283

    
284
    // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
285
    function exec(command: string, options: { encoding: "buffer" | null } & ExecOptions, callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
286

    
287
    // `options` with well known `encoding` means stdout/stderr are definitely `string`.
288
    function exec(command: string, options: { encoding: BufferEncoding } & ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
289

    
290
    // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
291
    // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
292
    function exec(command: string, options: { encoding: string } & ExecOptions, callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
293

    
294
    // `options` without an `encoding` means stdout/stderr are definitely `string`.
295
    function exec(command: string, options: ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
296

    
297
    // fallback if nothing else matches. Worst case is always `string | Buffer`.
298
    function exec(
299
        command: string,
300
        options: ({ encoding?: string | null } & ExecOptions) | undefined | null,
301
        callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
302
    ): ChildProcess;
303

    
304
    interface PromiseWithChild<T> extends Promise<T> {
305
        child: ChildProcess;
306
    }
307

    
308
    // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
309
    namespace exec {
310
        function __promisify__(command: string): PromiseWithChild<{ stdout: string, stderr: string }>;
311
        function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
312
        function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
313
        function __promisify__(command: string, options: ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
314
        function __promisify__(command: string, options?: ({ encoding?: string | null } & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
315
    }
316

    
317
    interface ExecFileOptions extends CommonOptions {
318
        maxBuffer?: number;
319
        killSignal?: NodeJS.Signals | number;
320
        windowsVerbatimArguments?: boolean;
321
        shell?: boolean | string;
322
    }
323
    interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
324
        encoding: BufferEncoding;
325
    }
326
    interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
327
        encoding: 'buffer' | null;
328
    }
329
    interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
330
        encoding: string;
331
    }
332

    
333
    function execFile(file: string): ChildProcess;
334
    function execFile(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
335
    function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
336
    function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): ChildProcess;
337

    
338
    // no `options` definitely means stdout/stderr are `string`.
339
    function execFile(file: string, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
340
    function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
341

    
342
    // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
343
    function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
344
    function execFile(
345
        file: string,
346
        args: ReadonlyArray<string> | undefined | null,
347
        options: ExecFileOptionsWithBufferEncoding,
348
        callback: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void,
349
    ): ChildProcess;
350

    
351
    // `options` with well known `encoding` means stdout/stderr are definitely `string`.
352
    function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
353
    function execFile(
354
        file: string,
355
        args: ReadonlyArray<string> | undefined | null,
356
        options: ExecFileOptionsWithStringEncoding,
357
        callback: (error: ExecException | null, stdout: string, stderr: string) => void,
358
    ): ChildProcess;
359

    
360
    // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
361
    // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
362
    function execFile(
363
        file: string,
364
        options: ExecFileOptionsWithOtherEncoding,
365
        callback: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
366
    ): ChildProcess;
367
    function execFile(
368
        file: string,
369
        args: ReadonlyArray<string> | undefined | null,
370
        options: ExecFileOptionsWithOtherEncoding,
371
        callback: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
372
    ): ChildProcess;
373

    
374
    // `options` without an `encoding` means stdout/stderr are definitely `string`.
375
    function execFile(file: string, options: ExecFileOptions, callback: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
376
    function execFile(
377
        file: string,
378
        args: ReadonlyArray<string> | undefined | null,
379
        options: ExecFileOptions,
380
        callback: (error: ExecException | null, stdout: string, stderr: string) => void
381
    ): ChildProcess;
382

    
383
    // fallback if nothing else matches. Worst case is always `string | Buffer`.
384
    function execFile(
385
        file: string,
386
        options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
387
        callback: ((error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
388
    ): ChildProcess;
389
    function execFile(
390
        file: string,
391
        args: ReadonlyArray<string> | undefined | null,
392
        options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
393
        callback: ((error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
394
    ): ChildProcess;
395

    
396
    // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
397
    namespace execFile {
398
        function __promisify__(file: string): PromiseWithChild<{ stdout: string, stderr: string }>;
399
        function __promisify__(file: string, args: string[] | undefined | null): PromiseWithChild<{ stdout: string, stderr: string }>;
400
        function __promisify__(file: string, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
401
        function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
402
        function __promisify__(file: string, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
403
        function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
404
        function __promisify__(file: string, options: ExecFileOptionsWithOtherEncoding): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
405
        function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptionsWithOtherEncoding): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
406
        function __promisify__(file: string, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
407
        function __promisify__(file: string, args: string[] | undefined | null, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
408
        function __promisify__(file: string, options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
409
        function __promisify__(
410
            file: string,
411
            args: string[] | undefined | null,
412
            options: ({ encoding?: string | null } & ExecFileOptions) | undefined | null,
413
        ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
414
    }
415

    
416
    interface ForkOptions extends ProcessEnvOptions, MessagingOptions {
417
        execPath?: string;
418
        execArgv?: string[];
419
        silent?: boolean;
420
        stdio?: StdioOptions;
421
        detached?: boolean;
422
        windowsVerbatimArguments?: boolean;
423
    }
424
    function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
425

    
426
    interface SpawnSyncOptions extends CommonSpawnOptions {
427
        input?: string | NodeJS.ArrayBufferView;
428
        killSignal?: NodeJS.Signals | number;
429
        maxBuffer?: number;
430
        encoding?: string;
431
    }
432
    interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
433
        encoding: BufferEncoding;
434
    }
435
    interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
436
        encoding: string; // specify `null`.
437
    }
438
    interface SpawnSyncReturns<T> {
439
        pid: number;
440
        output: string[];
441
        stdout: T;
442
        stderr: T;
443
        status: number | null;
444
        signal: NodeJS.Signals | null;
445
        error?: Error;
446
    }
447
    function spawnSync(command: string): SpawnSyncReturns<Buffer>;
448
    function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
449
    function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
450
    function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
451
    function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
452
    function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
453
    function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
454

    
455
    interface ExecSyncOptions extends CommonOptions {
456
        input?: string | Uint8Array;
457
        stdio?: StdioOptions;
458
        shell?: string;
459
        killSignal?: NodeJS.Signals | number;
460
        maxBuffer?: number;
461
        encoding?: string;
462
    }
463
    interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
464
        encoding: BufferEncoding;
465
    }
466
    interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
467
        encoding: string; // specify `null`.
468
    }
469
    function execSync(command: string): Buffer;
470
    function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
471
    function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
472
    function execSync(command: string, options?: ExecSyncOptions): Buffer;
473

    
474
    interface ExecFileSyncOptions extends CommonOptions {
475
        input?: string | NodeJS.ArrayBufferView;
476
        stdio?: StdioOptions;
477
        killSignal?: NodeJS.Signals | number;
478
        maxBuffer?: number;
479
        encoding?: string;
480
        shell?: boolean | string;
481
    }
482
    interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
483
        encoding: BufferEncoding;
484
    }
485
    interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
486
        encoding: string; // specify `null`.
487
    }
488
    function execFileSync(command: string): Buffer;
489
    function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
490
    function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
491
    function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
492
    function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithStringEncoding): string;
493
    function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
494
    function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): Buffer;
495
}
(7-7/45)