@aligent/cdk-prerender-proxy 0.2.4 → 0.2.5-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/lib/handlers/cache-control.ts +7 -20
  2. package/lib/handlers/error-response.ts +8 -51
  3. package/lib/handlers/node_modules/.package-lock.json +32 -3
  4. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/index.d.ts +6 -0
  5. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/index.js +14 -0
  6. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/cache-control.d.ts +3 -0
  7. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/cache-control.js +24 -0
  8. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/error-response.d.ts +3 -0
  9. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/error-response.js +50 -0
  10. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender-check.d.ts +3 -0
  11. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender-check.js +28 -0
  12. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender.d.ts +3 -0
  13. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender.js +49 -0
  14. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/redirect.d.ts +3 -0
  15. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/redirect.js +33 -0
  16. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/package.json +27 -0
  17. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/tsconfig.json +3 -0
  18. package/lib/handlers/node_modules/@middy/core/LICENSE +21 -0
  19. package/lib/handlers/node_modules/@middy/core/README.md +65 -0
  20. package/lib/handlers/node_modules/@middy/core/index.cjs +207 -0
  21. package/lib/handlers/node_modules/@middy/core/index.d.ts +91 -0
  22. package/lib/handlers/node_modules/@middy/core/index.js +199 -0
  23. package/lib/handlers/node_modules/@middy/core/package.json +65 -0
  24. package/lib/handlers/node_modules/@types/node/README.md +4 -4
  25. package/lib/handlers/node_modules/@types/node/assert/strict.d.ts +5 -1
  26. package/lib/handlers/node_modules/@types/node/assert.d.ts +904 -67
  27. package/lib/handlers/node_modules/@types/node/async_hooks.d.ts +371 -96
  28. package/lib/handlers/node_modules/@types/node/buffer.d.ts +2199 -25
  29. package/lib/handlers/node_modules/@types/node/child_process.d.ts +1151 -308
  30. package/lib/handlers/node_modules/@types/node/cluster.d.ts +356 -208
  31. package/lib/handlers/node_modules/@types/node/console.d.ts +324 -45
  32. package/lib/handlers/node_modules/@types/node/constants.d.ts +8 -3
  33. package/lib/handlers/node_modules/@types/node/crypto.d.ts +3230 -846
  34. package/lib/handlers/node_modules/@types/node/dgram.d.ts +478 -74
  35. package/lib/handlers/node_modules/@types/node/diagnostics_channel.d.ts +153 -0
  36. package/lib/handlers/node_modules/@types/node/dns/promises.d.ts +308 -35
  37. package/lib/handlers/node_modules/@types/node/dns.d.ts +444 -107
  38. package/lib/handlers/node_modules/@types/node/dom-events.d.ts +126 -0
  39. package/lib/handlers/node_modules/@types/node/domain.d.ts +162 -16
  40. package/lib/handlers/node_modules/@types/node/events.d.ts +624 -39
  41. package/lib/handlers/node_modules/@types/node/fs/promises.d.ts +911 -365
  42. package/lib/handlers/node_modules/@types/node/fs.d.ts +2611 -978
  43. package/lib/handlers/node_modules/@types/node/globals.d.ts +66 -421
  44. package/lib/handlers/node_modules/@types/node/globals.global.d.ts +1 -1
  45. package/lib/handlers/node_modules/@types/node/http.d.ts +1416 -199
  46. package/lib/handlers/node_modules/@types/node/http2.d.ts +1688 -530
  47. package/lib/handlers/node_modules/@types/node/https.d.ts +532 -26
  48. package/lib/handlers/node_modules/@types/node/index.d.ts +92 -16
  49. package/lib/handlers/node_modules/@types/node/inspector.d.ts +511 -811
  50. package/lib/handlers/node_modules/@types/node/module.d.ts +75 -13
  51. package/lib/handlers/node_modules/@types/node/net.d.ts +710 -167
  52. package/lib/handlers/node_modules/@types/node/os.d.ts +252 -25
  53. package/lib/handlers/node_modules/@types/node/package.json +30 -25
  54. package/lib/handlers/node_modules/@types/node/path.d.ts +59 -31
  55. package/lib/handlers/node_modules/@types/node/perf_hooks.d.ts +420 -105
  56. package/lib/handlers/node_modules/@types/node/process.d.ts +1249 -228
  57. package/lib/handlers/node_modules/@types/node/punycode.d.ts +67 -25
  58. package/lib/handlers/node_modules/@types/node/querystring.d.ts +113 -10
  59. package/lib/handlers/node_modules/@types/node/readline/promises.d.ts +143 -0
  60. package/lib/handlers/node_modules/@types/node/readline.d.ts +570 -109
  61. package/lib/handlers/node_modules/@types/node/repl.d.ts +154 -125
  62. package/lib/handlers/node_modules/@types/node/stream/consumers.d.ts +12 -0
  63. package/lib/handlers/node_modules/@types/node/stream/promises.d.ts +18 -43
  64. package/lib/handlers/node_modules/@types/node/stream/web.d.ts +330 -0
  65. package/lib/handlers/node_modules/@types/node/stream.d.ts +1117 -248
  66. package/lib/handlers/node_modules/@types/node/string_decoder.d.ts +60 -0
  67. package/lib/handlers/node_modules/@types/node/test.d.ts +446 -0
  68. package/lib/handlers/node_modules/@types/node/timers/promises.d.ts +81 -9
  69. package/lib/handlers/node_modules/@types/node/timers.d.ts +84 -17
  70. package/lib/handlers/node_modules/@types/node/tls.d.ts +510 -275
  71. package/lib/handlers/node_modules/@types/node/trace_events.d.ts +120 -10
  72. package/lib/handlers/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
  73. package/lib/handlers/node_modules/@types/node/ts4.8/assert.d.ts +961 -0
  74. package/lib/handlers/node_modules/@types/node/ts4.8/async_hooks.d.ts +501 -0
  75. package/lib/handlers/node_modules/@types/node/ts4.8/buffer.d.ts +2259 -0
  76. package/lib/handlers/node_modules/@types/node/ts4.8/child_process.d.ts +1369 -0
  77. package/lib/handlers/node_modules/@types/node/ts4.8/cluster.d.ts +410 -0
  78. package/lib/handlers/node_modules/@types/node/ts4.8/console.d.ts +412 -0
  79. package/lib/handlers/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
  80. package/lib/handlers/node_modules/@types/node/ts4.8/crypto.d.ts +3964 -0
  81. package/lib/handlers/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
  82. package/lib/handlers/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +153 -0
  83. package/lib/handlers/node_modules/@types/node/ts4.8/dns/promises.d.ts +370 -0
  84. package/lib/handlers/node_modules/@types/node/ts4.8/dns.d.ts +659 -0
  85. package/lib/handlers/node_modules/@types/node/ts4.8/dom-events.d.ts +126 -0
  86. package/lib/handlers/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
  87. package/lib/handlers/node_modules/@types/node/ts4.8/events.d.ts +678 -0
  88. package/lib/handlers/node_modules/@types/node/ts4.8/fs/promises.d.ts +1138 -0
  89. package/lib/handlers/node_modules/@types/node/ts4.8/fs.d.ts +3872 -0
  90. package/lib/handlers/node_modules/@types/node/ts4.8/globals.d.ts +294 -0
  91. package/lib/handlers/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  92. package/lib/handlers/node_modules/@types/node/ts4.8/http.d.ts +1651 -0
  93. package/lib/handlers/node_modules/@types/node/ts4.8/http2.d.ts +2134 -0
  94. package/lib/handlers/node_modules/@types/node/ts4.8/https.d.ts +542 -0
  95. package/lib/handlers/node_modules/@types/node/ts4.8/index.d.ts +88 -0
  96. package/lib/handlers/node_modules/@types/node/ts4.8/inspector.d.ts +2741 -0
  97. package/lib/handlers/node_modules/@types/node/ts4.8/module.d.ts +114 -0
  98. package/lib/handlers/node_modules/@types/node/ts4.8/net.d.ts +869 -0
  99. package/lib/handlers/node_modules/@types/node/ts4.8/os.d.ts +466 -0
  100. package/lib/handlers/node_modules/@types/node/ts4.8/path.d.ts +191 -0
  101. package/lib/handlers/node_modules/@types/node/ts4.8/perf_hooks.d.ts +625 -0
  102. package/lib/handlers/node_modules/@types/node/ts4.8/process.d.ts +1482 -0
  103. package/lib/handlers/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
  104. package/lib/handlers/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
  105. package/lib/handlers/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
  106. package/lib/handlers/node_modules/@types/node/ts4.8/readline.d.ts +653 -0
  107. package/lib/handlers/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
  108. package/lib/handlers/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
  109. package/lib/handlers/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
  110. package/lib/handlers/node_modules/@types/node/ts4.8/stream/web.d.ts +330 -0
  111. package/lib/handlers/node_modules/@types/node/ts4.8/stream.d.ts +1340 -0
  112. package/lib/handlers/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
  113. package/lib/handlers/node_modules/@types/node/ts4.8/test.d.ts +446 -0
  114. package/lib/handlers/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
  115. package/lib/handlers/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
  116. package/lib/handlers/node_modules/@types/node/ts4.8/tls.d.ts +1028 -0
  117. package/lib/handlers/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
  118. package/lib/handlers/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
  119. package/lib/handlers/node_modules/@types/node/ts4.8/url.d.ts +897 -0
  120. package/lib/handlers/node_modules/@types/node/ts4.8/util.d.ts +1926 -0
  121. package/lib/handlers/node_modules/@types/node/ts4.8/v8.d.ts +396 -0
  122. package/lib/handlers/node_modules/@types/node/ts4.8/vm.d.ts +509 -0
  123. package/lib/handlers/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
  124. package/lib/handlers/node_modules/@types/node/ts4.8/worker_threads.d.ts +689 -0
  125. package/lib/handlers/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
  126. package/lib/handlers/node_modules/@types/node/tty.d.ts +163 -23
  127. package/lib/handlers/node_modules/@types/node/url.d.ts +825 -44
  128. package/lib/handlers/node_modules/@types/node/util.d.ts +1842 -72
  129. package/lib/handlers/node_modules/@types/node/v8.d.ts +276 -78
  130. package/lib/handlers/node_modules/@types/node/vm.d.ts +410 -53
  131. package/lib/handlers/node_modules/@types/node/wasi.d.ts +102 -30
  132. package/lib/handlers/node_modules/@types/node/worker_threads.d.ts +559 -152
  133. package/lib/handlers/node_modules/@types/node/zlib.d.ts +234 -78
  134. package/lib/handlers/node_modules/esbuild/README.md +3 -0
  135. package/lib/handlers/node_modules/esbuild/bin/esbuild +0 -0
  136. package/lib/handlers/node_modules/esbuild/install.js +256 -0
  137. package/lib/handlers/node_modules/esbuild/lib/main.d.ts +397 -0
  138. package/lib/handlers/node_modules/esbuild/lib/main.js +1939 -0
  139. package/lib/handlers/node_modules/esbuild/package.json +15 -0
  140. package/lib/handlers/package-lock.json +62 -6
  141. package/lib/handlers/package.json +6 -1
  142. package/lib/handlers/prerender-check.ts +8 -27
  143. package/lib/handlers/prerender.ts +8 -43
  144. package/package.json +1 -1
  145. package/lib/handlers/node_modules/@types/node/base.d.ts +0 -19
  146. package/lib/handlers/node_modules/@types/node/diagnostic_channel.d.ts +0 -34
  147. package/lib/handlers/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  148. package/lib/handlers/node_modules/@types/node/ts3.6/base.d.ts +0 -68
  149. package/lib/handlers/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  150. package/lib/handlers/node_modules/@types/node/util/types.d.ts +0 -53
@@ -1,39 +1,518 @@
1
+ /**
2
+ * The `child_process` module provides the ability to spawn subprocesses in
3
+ * a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability
4
+ * is primarily provided by the {@link spawn} function:
5
+ *
6
+ * ```js
7
+ * const { spawn } = require('child_process');
8
+ * const ls = spawn('ls', ['-lh', '/usr']);
9
+ *
10
+ * ls.stdout.on('data', (data) => {
11
+ * console.log(`stdout: ${data}`);
12
+ * });
13
+ *
14
+ * ls.stderr.on('data', (data) => {
15
+ * console.error(`stderr: ${data}`);
16
+ * });
17
+ *
18
+ * ls.on('close', (code) => {
19
+ * console.log(`child process exited with code ${code}`);
20
+ * });
21
+ * ```
22
+ *
23
+ * By default, pipes for `stdin`, `stdout`, and `stderr` are established between
24
+ * the parent Node.js process and the spawned subprocess. These pipes have
25
+ * limited (and platform-specific) capacity. If the subprocess writes to
26
+ * stdout in excess of that limit without the output being captured, the
27
+ * subprocess blocks waiting for the pipe buffer to accept more data. This is
28
+ * identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed.
29
+ *
30
+ * The command lookup is performed using the `options.env.PATH` environment
31
+ * variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
32
+ * used. If `options.env` is set without `PATH`, lookup on Unix is performed
33
+ * on a default search path search of `/usr/bin:/bin` (see your operating system's
34
+ * manual for execvpe/execvp), on Windows the current processes environment
35
+ * variable `PATH` is used.
36
+ *
37
+ * On Windows, environment variables are case-insensitive. Node.js
38
+ * lexicographically sorts the `env` keys and uses the first one that
39
+ * case-insensitively matches. Only first (in lexicographic order) entry will be
40
+ * passed to the subprocess. This might lead to issues on Windows when passing
41
+ * objects to the `env` option that have multiple variants of the same key, such as`PATH` and `Path`.
42
+ *
43
+ * The {@link spawn} method spawns the child process asynchronously,
44
+ * without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
45
+ * the event loop until the spawned process either exits or is terminated.
46
+ *
47
+ * For convenience, the `child_process` module provides a handful of synchronous
48
+ * and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
49
+ * top of {@link spawn} or {@link spawnSync}.
50
+ *
51
+ * * {@link exec}: spawns a shell and runs a command within that
52
+ * shell, passing the `stdout` and `stderr` to a callback function when
53
+ * complete.
54
+ * * {@link execFile}: similar to {@link exec} except
55
+ * that it spawns the command directly without first spawning a shell by
56
+ * default.
57
+ * * {@link fork}: spawns a new Node.js process and invokes a
58
+ * specified module with an IPC communication channel established that allows
59
+ * sending messages between parent and child.
60
+ * * {@link execSync}: a synchronous version of {@link exec} that will block the Node.js event loop.
61
+ * * {@link execFileSync}: a synchronous version of {@link execFile} that will block the Node.js event loop.
62
+ *
63
+ * For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
64
+ * the synchronous methods can have significant impact on performance due to
65
+ * stalling the event loop while spawned processes complete.
66
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/child_process.js)
67
+ */
1
68
  declare 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
-
69
+ import { ObjectEncodingOptions } from 'node:fs';
70
+ import { EventEmitter, Abortable } from 'node:events';
71
+ import * as net from 'node:net';
72
+ import { Writable, Readable, Stream, Pipe } from 'node:stream';
73
+ import { URL } from 'node:url';
7
74
  type Serializable = string | object | number | boolean | bigint;
8
75
  type SendHandle = net.Socket | net.Server;
9
-
10
- interface ChildProcess extends EventEmitter {
76
+ /**
77
+ * Instances of the `ChildProcess` represent spawned child processes.
78
+ *
79
+ * Instances of `ChildProcess` are not intended to be created directly. Rather,
80
+ * use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create
81
+ * instances of `ChildProcess`.
82
+ * @since v2.2.0
83
+ */
84
+ class ChildProcess extends EventEmitter {
85
+ /**
86
+ * A `Writable Stream` that represents the child process's `stdin`.
87
+ *
88
+ * If a child process waits to read all of its input, the child will not continue
89
+ * until this stream has been closed via `end()`.
90
+ *
91
+ * If the child was spawned with `stdio[0]` set to anything other than `'pipe'`,
92
+ * then this will be `null`.
93
+ *
94
+ * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
95
+ * refer to the same value.
96
+ *
97
+ * The `subprocess.stdin` property can be `undefined` if the child process could
98
+ * not be successfully spawned.
99
+ * @since v0.1.90
100
+ */
11
101
  stdin: Writable | null;
102
+ /**
103
+ * A `Readable Stream` that represents the child process's `stdout`.
104
+ *
105
+ * If the child was spawned with `stdio[1]` set to anything other than `'pipe'`,
106
+ * then this will be `null`.
107
+ *
108
+ * `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
109
+ * refer to the same value.
110
+ *
111
+ * ```js
112
+ * const { spawn } = require('child_process');
113
+ *
114
+ * const subprocess = spawn('ls');
115
+ *
116
+ * subprocess.stdout.on('data', (data) => {
117
+ * console.log(`Received chunk ${data}`);
118
+ * });
119
+ * ```
120
+ *
121
+ * The `subprocess.stdout` property can be `null` if the child process could
122
+ * not be successfully spawned.
123
+ * @since v0.1.90
124
+ */
12
125
  stdout: Readable | null;
126
+ /**
127
+ * A `Readable Stream` that represents the child process's `stderr`.
128
+ *
129
+ * If the child was spawned with `stdio[2]` set to anything other than `'pipe'`,
130
+ * then this will be `null`.
131
+ *
132
+ * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
133
+ * refer to the same value.
134
+ *
135
+ * The `subprocess.stderr` property can be `null` if the child process could
136
+ * not be successfully spawned.
137
+ * @since v0.1.90
138
+ */
13
139
  stderr: Readable | null;
14
- readonly channel?: Pipe | null;
140
+ /**
141
+ * The `subprocess.channel` property is a reference to the child's IPC channel. If
142
+ * no IPC channel currently exists, this property is `undefined`.
143
+ * @since v7.1.0
144
+ */
145
+ readonly channel?: Pipe | null | undefined;
146
+ /**
147
+ * A sparse array of pipes to the child process, corresponding with positions in
148
+ * the `stdio` option passed to {@link spawn} that have been set
149
+ * to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and`subprocess.stdio[2]` are also available as `subprocess.stdin`,`subprocess.stdout`, and `subprocess.stderr`,
150
+ * respectively.
151
+ *
152
+ * In the following example, only the child's fd `1` (stdout) is configured as a
153
+ * pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values
154
+ * in the array are `null`.
155
+ *
156
+ * ```js
157
+ * const assert = require('assert');
158
+ * const fs = require('fs');
159
+ * const child_process = require('child_process');
160
+ *
161
+ * const subprocess = child_process.spawn('ls', {
162
+ * stdio: [
163
+ * 0, // Use parent's stdin for child.
164
+ * 'pipe', // Pipe child's stdout to parent.
165
+ * fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
166
+ * ]
167
+ * });
168
+ *
169
+ * assert.strictEqual(subprocess.stdio[0], null);
170
+ * assert.strictEqual(subprocess.stdio[0], subprocess.stdin);
171
+ *
172
+ * assert(subprocess.stdout);
173
+ * assert.strictEqual(subprocess.stdio[1], subprocess.stdout);
174
+ *
175
+ * assert.strictEqual(subprocess.stdio[2], null);
176
+ * assert.strictEqual(subprocess.stdio[2], subprocess.stderr);
177
+ * ```
178
+ *
179
+ * The `subprocess.stdio` property can be `undefined` if the child process could
180
+ * not be successfully spawned.
181
+ * @since v0.7.10
182
+ */
15
183
  readonly stdio: [
16
- Writable | null, // stdin
17
- Readable | null, // stdout
18
- Readable | null, // stderr
19
- Readable | Writable | null | undefined, // extra
184
+ Writable | null,
185
+ // stdin
186
+ Readable | null,
187
+ // stdout
188
+ Readable | null,
189
+ // stderr
190
+ Readable | Writable | null | undefined,
191
+ // extra
20
192
  Readable | Writable | null | undefined // extra
21
193
  ];
194
+ /**
195
+ * The `subprocess.killed` property indicates whether the child process
196
+ * successfully received a signal from `subprocess.kill()`. The `killed` property
197
+ * does not indicate that the child process has been terminated.
198
+ * @since v0.5.10
199
+ */
22
200
  readonly killed: boolean;
23
- readonly pid?: number;
201
+ /**
202
+ * Returns the process identifier (PID) of the child process. If the child process
203
+ * fails to spawn due to errors, then the value is `undefined` and `error` is
204
+ * emitted.
205
+ *
206
+ * ```js
207
+ * const { spawn } = require('child_process');
208
+ * const grep = spawn('grep', ['ssh']);
209
+ *
210
+ * console.log(`Spawned child pid: ${grep.pid}`);
211
+ * grep.stdin.end();
212
+ * ```
213
+ * @since v0.1.90
214
+ */
215
+ readonly pid?: number | undefined;
216
+ /**
217
+ * The `subprocess.connected` property indicates whether it is still possible to
218
+ * send and receive messages from a child process. When `subprocess.connected` is`false`, it is no longer possible to send or receive messages.
219
+ * @since v0.7.2
220
+ */
24
221
  readonly connected: boolean;
222
+ /**
223
+ * The `subprocess.exitCode` property indicates the exit code of the child process.
224
+ * If the child process is still running, the field will be `null`.
225
+ */
25
226
  readonly exitCode: number | null;
227
+ /**
228
+ * The `subprocess.signalCode` property indicates the signal received by
229
+ * the child process if any, else `null`.
230
+ */
26
231
  readonly signalCode: NodeJS.Signals | null;
232
+ /**
233
+ * The `subprocess.spawnargs` property represents the full list of command-line
234
+ * arguments the child process was launched with.
235
+ */
27
236
  readonly spawnargs: string[];
237
+ /**
238
+ * The `subprocess.spawnfile` property indicates the executable file name of
239
+ * the child process that is launched.
240
+ *
241
+ * For {@link fork}, its value will be equal to `process.execPath`.
242
+ * For {@link spawn}, its value will be the name of
243
+ * the executable file.
244
+ * For {@link exec}, its value will be the name of the shell
245
+ * in which the child process is launched.
246
+ */
28
247
  readonly spawnfile: string;
248
+ /**
249
+ * The `subprocess.kill()` method sends a signal to the child process. If no
250
+ * argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function
251
+ * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
252
+ *
253
+ * ```js
254
+ * const { spawn } = require('child_process');
255
+ * const grep = spawn('grep', ['ssh']);
256
+ *
257
+ * grep.on('close', (code, signal) => {
258
+ * console.log(
259
+ * `child process terminated due to receipt of signal ${signal}`);
260
+ * });
261
+ *
262
+ * // Send SIGHUP to process.
263
+ * grep.kill('SIGHUP');
264
+ * ```
265
+ *
266
+ * The `ChildProcess` object may emit an `'error'` event if the signal
267
+ * cannot be delivered. Sending a signal to a child process that has already exited
268
+ * is not an error but may have unforeseen consequences. Specifically, if the
269
+ * process identifier (PID) has been reassigned to another process, the signal will
270
+ * be delivered to that process instead which can have unexpected results.
271
+ *
272
+ * While the function is called `kill`, the signal delivered to the child process
273
+ * may not actually terminate the process.
274
+ *
275
+ * See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
276
+ *
277
+ * On Windows, where POSIX signals do not exist, the `signal` argument will be
278
+ * ignored, and the process will be killed forcefully and abruptly (similar to`'SIGKILL'`).
279
+ * See `Signal Events` for more details.
280
+ *
281
+ * On Linux, child processes of child processes will not be terminated
282
+ * when attempting to kill their parent. This is likely to happen when running a
283
+ * new process in a shell or with the use of the `shell` option of `ChildProcess`:
284
+ *
285
+ * ```js
286
+ * 'use strict';
287
+ * const { spawn } = require('child_process');
288
+ *
289
+ * const subprocess = spawn(
290
+ * 'sh',
291
+ * [
292
+ * '-c',
293
+ * `node -e "setInterval(() => {
294
+ * console.log(process.pid, 'is alive')
295
+ * }, 500);"`,
296
+ * ], {
297
+ * stdio: ['inherit', 'inherit', 'inherit']
298
+ * }
299
+ * );
300
+ *
301
+ * setTimeout(() => {
302
+ * subprocess.kill(); // Does not terminate the Node.js process in the shell.
303
+ * }, 2000);
304
+ * ```
305
+ * @since v0.1.90
306
+ */
29
307
  kill(signal?: NodeJS.Signals | number): boolean;
308
+ /**
309
+ * When an IPC channel has been established between the parent and child (
310
+ * i.e. when using {@link fork}), the `subprocess.send()` method can
311
+ * be used to send messages to the child process. When the child process is a
312
+ * Node.js instance, these messages can be received via the `'message'` event.
313
+ *
314
+ * The message goes through serialization and parsing. The resulting
315
+ * message might not be the same as what is originally sent.
316
+ *
317
+ * For example, in the parent script:
318
+ *
319
+ * ```js
320
+ * const cp = require('child_process');
321
+ * const n = cp.fork(`${__dirname}/sub.js`);
322
+ *
323
+ * n.on('message', (m) => {
324
+ * console.log('PARENT got message:', m);
325
+ * });
326
+ *
327
+ * // Causes the child to print: CHILD got message: { hello: 'world' }
328
+ * n.send({ hello: 'world' });
329
+ * ```
330
+ *
331
+ * And then the child script, `'sub.js'` might look like this:
332
+ *
333
+ * ```js
334
+ * process.on('message', (m) => {
335
+ * console.log('CHILD got message:', m);
336
+ * });
337
+ *
338
+ * // Causes the parent to print: PARENT got message: { foo: 'bar', baz: null }
339
+ * process.send({ foo: 'bar', baz: NaN });
340
+ * ```
341
+ *
342
+ * Child Node.js processes will have a `process.send()` method of their own
343
+ * that allows the child to send messages back to the parent.
344
+ *
345
+ * There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages
346
+ * containing a `NODE_` prefix in the `cmd` property are reserved for use within
347
+ * Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the`'internalMessage'` event and are consumed internally by Node.js.
348
+ * Applications should avoid using such messages or listening for`'internalMessage'` events as it is subject to change without notice.
349
+ *
350
+ * The optional `sendHandle` argument that may be passed to `subprocess.send()` is
351
+ * for passing a TCP server or socket object to the child process. The child will
352
+ * receive the object as the second argument passed to the callback function
353
+ * registered on the `'message'` event. Any data that is received
354
+ * and buffered in the socket will not be sent to the child.
355
+ *
356
+ * The optional `callback` is a function that is invoked after the message is
357
+ * sent but before the child may have received it. The function is called with a
358
+ * single argument: `null` on success, or an `Error` object on failure.
359
+ *
360
+ * If no `callback` function is provided and the message cannot be sent, an`'error'` event will be emitted by the `ChildProcess` object. This can
361
+ * happen, for instance, when the child process has already exited.
362
+ *
363
+ * `subprocess.send()` will return `false` if the channel has closed or when the
364
+ * backlog of unsent messages exceeds a threshold that makes it unwise to send
365
+ * more. Otherwise, the method returns `true`. The `callback` function can be
366
+ * used to implement flow control.
367
+ *
368
+ * #### Example: sending a server object
369
+ *
370
+ * The `sendHandle` argument can be used, for instance, to pass the handle of
371
+ * a TCP server object to the child process as illustrated in the example below:
372
+ *
373
+ * ```js
374
+ * const subprocess = require('child_process').fork('subprocess.js');
375
+ *
376
+ * // Open up the server object and send the handle.
377
+ * const server = require('net').createServer();
378
+ * server.on('connection', (socket) => {
379
+ * socket.end('handled by parent');
380
+ * });
381
+ * server.listen(1337, () => {
382
+ * subprocess.send('server', server);
383
+ * });
384
+ * ```
385
+ *
386
+ * The child would then receive the server object as:
387
+ *
388
+ * ```js
389
+ * process.on('message', (m, server) => {
390
+ * if (m === 'server') {
391
+ * server.on('connection', (socket) => {
392
+ * socket.end('handled by child');
393
+ * });
394
+ * }
395
+ * });
396
+ * ```
397
+ *
398
+ * Once the server is now shared between the parent and child, some connections
399
+ * can be handled by the parent and some by the child.
400
+ *
401
+ * While the example above uses a server created using the `net` module, `dgram`module servers use exactly the same workflow with the exceptions of listening on
402
+ * a `'message'` event instead of `'connection'` and using `server.bind()` instead
403
+ * of `server.listen()`. This is, however, currently only supported on Unix
404
+ * platforms.
405
+ *
406
+ * #### Example: sending a socket object
407
+ *
408
+ * Similarly, the `sendHandler` argument can be used to pass the handle of a
409
+ * socket to the child process. The example below spawns two children that each
410
+ * handle connections with "normal" or "special" priority:
411
+ *
412
+ * ```js
413
+ * const { fork } = require('child_process');
414
+ * const normal = fork('subprocess.js', ['normal']);
415
+ * const special = fork('subprocess.js', ['special']);
416
+ *
417
+ * // Open up the server and send sockets to child. Use pauseOnConnect to prevent
418
+ * // the sockets from being read before they are sent to the child process.
419
+ * const server = require('net').createServer({ pauseOnConnect: true });
420
+ * server.on('connection', (socket) => {
421
+ *
422
+ * // If this is special priority...
423
+ * if (socket.remoteAddress === '74.125.127.100') {
424
+ * special.send('socket', socket);
425
+ * return;
426
+ * }
427
+ * // This is normal priority.
428
+ * normal.send('socket', socket);
429
+ * });
430
+ * server.listen(1337);
431
+ * ```
432
+ *
433
+ * The `subprocess.js` would receive the socket handle as the second argument
434
+ * passed to the event callback function:
435
+ *
436
+ * ```js
437
+ * process.on('message', (m, socket) => {
438
+ * if (m === 'socket') {
439
+ * if (socket) {
440
+ * // Check that the client socket exists.
441
+ * // It is possible for the socket to be closed between the time it is
442
+ * // sent and the time it is received in the child process.
443
+ * socket.end(`Request handled with ${process.argv[2]} priority`);
444
+ * }
445
+ * }
446
+ * });
447
+ * ```
448
+ *
449
+ * Do not use `.maxConnections` on a socket that has been passed to a subprocess.
450
+ * The parent cannot track when the socket is destroyed.
451
+ *
452
+ * Any `'message'` handlers in the subprocess should verify that `socket` exists,
453
+ * as the connection may have been closed during the time it takes to send the
454
+ * connection to the child.
455
+ * @since v0.5.9
456
+ * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
457
+ */
30
458
  send(message: Serializable, callback?: (error: Error | null) => void): boolean;
31
459
  send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
32
460
  send(message: Serializable, sendHandle?: SendHandle, options?: MessageOptions, callback?: (error: Error | null) => void): boolean;
461
+ /**
462
+ * Closes the IPC channel between parent and child, allowing the child to exit
463
+ * gracefully once there are no other connections keeping it alive. After calling
464
+ * this method the `subprocess.connected` and `process.connected` properties in
465
+ * both the parent and child (respectively) will be set to `false`, and it will be
466
+ * no longer possible to pass messages between the processes.
467
+ *
468
+ * The `'disconnect'` event will be emitted when there are no messages in the
469
+ * process of being received. This will most often be triggered immediately after
470
+ * calling `subprocess.disconnect()`.
471
+ *
472
+ * When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked
473
+ * within the child process to close the IPC channel as well.
474
+ * @since v0.7.2
475
+ */
33
476
  disconnect(): void;
477
+ /**
478
+ * By default, the parent will wait for the detached child to exit. To prevent the
479
+ * parent from waiting for a given `subprocess` to exit, use the`subprocess.unref()` method. Doing so will cause the parent's event loop to not
480
+ * include the child in its reference count, allowing the parent to exit
481
+ * independently of the child, unless there is an established IPC channel between
482
+ * the child and the parent.
483
+ *
484
+ * ```js
485
+ * const { spawn } = require('child_process');
486
+ *
487
+ * const subprocess = spawn(process.argv[0], ['child_program.js'], {
488
+ * detached: true,
489
+ * stdio: 'ignore'
490
+ * });
491
+ *
492
+ * subprocess.unref();
493
+ * ```
494
+ * @since v0.7.10
495
+ */
34
496
  unref(): void;
497
+ /**
498
+ * Calling `subprocess.ref()` after making a call to `subprocess.unref()` will
499
+ * restore the removed reference count for the child process, forcing the parent
500
+ * to wait for the child to exit before exiting itself.
501
+ *
502
+ * ```js
503
+ * const { spawn } = require('child_process');
504
+ *
505
+ * const subprocess = spawn(process.argv[0], ['child_program.js'], {
506
+ * detached: true,
507
+ * stdio: 'ignore'
508
+ * });
509
+ *
510
+ * subprocess.unref();
511
+ * subprocess.ref();
512
+ * ```
513
+ * @since v0.7.10
514
+ */
35
515
  ref(): void;
36
-
37
516
  /**
38
517
  * events.EventEmitter
39
518
  * 1. close
@@ -43,76 +522,66 @@ declare module 'child_process' {
43
522
  * 5. message
44
523
  * 6. spawn
45
524
  */
46
-
47
525
  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
-
526
+ addListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
527
+ addListener(event: 'disconnect', listener: () => void): this;
528
+ addListener(event: 'error', listener: (err: Error) => void): this;
529
+ addListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
530
+ addListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
531
+ addListener(event: 'spawn', listener: () => void): this;
55
532
  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
-
533
+ emit(event: 'close', code: number | null, signal: NodeJS.Signals | null): boolean;
534
+ emit(event: 'disconnect'): boolean;
535
+ emit(event: 'error', err: Error): boolean;
536
+ emit(event: 'exit', code: number | null, signal: NodeJS.Signals | null): boolean;
537
+ emit(event: 'message', message: Serializable, sendHandle: SendHandle): boolean;
538
+ emit(event: 'spawn', listener: () => void): boolean;
63
539
  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
-
540
+ on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
541
+ on(event: 'disconnect', listener: () => void): this;
542
+ on(event: 'error', listener: (err: Error) => void): this;
543
+ on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
544
+ on(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
545
+ on(event: 'spawn', listener: () => void): this;
71
546
  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
-
547
+ once(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
548
+ once(event: 'disconnect', listener: () => void): this;
549
+ once(event: 'error', listener: (err: Error) => void): this;
550
+ once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
551
+ once(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
552
+ once(event: 'spawn', listener: () => void): this;
79
553
  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
-
554
+ prependListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
555
+ prependListener(event: 'disconnect', listener: () => void): this;
556
+ prependListener(event: 'error', listener: (err: Error) => void): this;
557
+ prependListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
558
+ prependListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
559
+ prependListener(event: 'spawn', listener: () => void): this;
87
560
  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
-
561
+ prependOnceListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
562
+ prependOnceListener(event: 'disconnect', listener: () => void): this;
563
+ prependOnceListener(event: 'error', listener: (err: Error) => void): this;
564
+ prependOnceListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
565
+ prependOnceListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
566
+ prependOnceListener(event: 'spawn', listener: () => void): this;
567
+ }
96
568
  // return this object when stdio option is undefined or not specified
97
569
  interface ChildProcessWithoutNullStreams extends ChildProcess {
98
570
  stdin: Writable;
99
571
  stdout: Readable;
100
572
  stderr: Readable;
101
573
  readonly stdio: [
102
- Writable, // stdin
103
- Readable, // stdout
104
- Readable, // stderr
105
- Readable | Writable | null | undefined, // extra, no modification
574
+ Writable,
575
+ Readable,
576
+ Readable,
577
+ // stderr
578
+ Readable | Writable | null | undefined,
579
+ // extra, no modification
106
580
  Readable | Writable | null | undefined // extra, no modification
107
581
  ];
108
582
  }
109
-
110
583
  // 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 {
584
+ interface ChildProcessByStdio<I extends null | Writable, O extends null | Readable, E extends null | Readable> extends ChildProcess {
116
585
  stdin: I;
117
586
  stdout: O;
118
587
  stderr: E;
@@ -120,231 +589,391 @@ declare module 'child_process' {
120
589
  I,
121
590
  O,
122
591
  E,
123
- Readable | Writable | null | undefined, // extra, no modification
592
+ Readable | Writable | null | undefined,
593
+ // extra, no modification
124
594
  Readable | Writable | null | undefined // extra, no modification
125
595
  ];
126
596
  }
127
-
128
597
  interface MessageOptions {
129
- keepOpen?: boolean;
598
+ keepOpen?: boolean | undefined;
130
599
  }
131
-
132
- type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
133
-
134
- type StdioOptions = IOType | Array<(IOType | "ipc" | Stream | number | null | undefined)>;
135
-
600
+ type IOType = 'overlapped' | 'pipe' | 'ignore' | 'inherit';
601
+ type StdioOptions = IOType | Array<IOType | 'ipc' | Stream | number | null | undefined>;
136
602
  type SerializationType = 'json' | 'advanced';
137
-
138
603
  interface MessagingOptions extends Abortable {
139
604
  /**
140
605
  * Specify the kind of serialization used for sending messages between processes.
141
606
  * @default 'json'
142
607
  */
143
- serialization?: SerializationType;
144
-
608
+ serialization?: SerializationType | undefined;
145
609
  /**
146
610
  * The signal value to be used when the spawned process will be killed by the abort signal.
147
611
  * @default 'SIGTERM'
148
612
  */
149
- killSignal?: NodeJS.Signals | number;
613
+ killSignal?: NodeJS.Signals | number | undefined;
614
+ /**
615
+ * In milliseconds the maximum amount of time the process is allowed to run.
616
+ */
617
+ timeout?: number | undefined;
150
618
  }
151
-
152
619
  interface ProcessEnvOptions {
153
- uid?: number;
154
- gid?: number;
155
- cwd?: string;
156
- env?: NodeJS.ProcessEnv;
620
+ uid?: number | undefined;
621
+ gid?: number | undefined;
622
+ cwd?: string | URL | undefined;
623
+ env?: NodeJS.ProcessEnv | undefined;
157
624
  }
158
-
159
625
  interface CommonOptions extends ProcessEnvOptions {
160
626
  /**
161
- * @default true
627
+ * @default false
162
628
  */
163
- windowsHide?: boolean;
629
+ windowsHide?: boolean | undefined;
164
630
  /**
165
631
  * @default 0
166
632
  */
167
- timeout?: number;
633
+ timeout?: number | undefined;
168
634
  }
169
-
170
635
  interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
171
- argv0?: string;
172
- stdio?: StdioOptions;
173
- shell?: boolean | string;
174
- windowsVerbatimArguments?: boolean;
636
+ argv0?: string | undefined;
637
+ stdio?: StdioOptions | undefined;
638
+ shell?: boolean | string | undefined;
639
+ windowsVerbatimArguments?: boolean | undefined;
175
640
  }
176
-
177
641
  interface SpawnOptions extends CommonSpawnOptions {
178
- detached?: boolean;
642
+ detached?: boolean | undefined;
179
643
  }
180
-
181
644
  interface SpawnOptionsWithoutStdio extends SpawnOptions {
182
- stdio?: StdioPipeNamed | StdioPipe[];
645
+ stdio?: StdioPipeNamed | StdioPipe[] | undefined;
183
646
  }
184
-
185
647
  type StdioNull = 'inherit' | 'ignore' | Stream;
186
648
  type StdioPipeNamed = 'pipe' | 'overlapped';
187
649
  type StdioPipe = undefined | null | StdioPipeNamed;
188
-
189
- interface SpawnOptionsWithStdioTuple<
190
- Stdin extends StdioNull | StdioPipe,
191
- Stdout extends StdioNull | StdioPipe,
192
- Stderr extends StdioNull | StdioPipe,
193
- > extends SpawnOptions {
650
+ interface SpawnOptionsWithStdioTuple<Stdin extends StdioNull | StdioPipe, Stdout extends StdioNull | StdioPipe, Stderr extends StdioNull | StdioPipe> extends SpawnOptions {
194
651
  stdio: [Stdin, Stdout, Stderr];
195
652
  }
196
-
197
- // overloads of spawn without 'args'
653
+ /**
654
+ * The `child_process.spawn()` method spawns a new process using the given`command`, with command-line arguments in `args`. If omitted, `args` defaults
655
+ * to an empty array.
656
+ *
657
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
658
+ * **function. Any input containing shell metacharacters may be used to trigger**
659
+ * **arbitrary command execution.**
660
+ *
661
+ * A third argument may be used to specify additional options, with these defaults:
662
+ *
663
+ * ```js
664
+ * const defaults = {
665
+ * cwd: undefined,
666
+ * env: process.env
667
+ * };
668
+ * ```
669
+ *
670
+ * Use `cwd` to specify the working directory from which the process is spawned.
671
+ * If not given, the default is to inherit the current working directory. If given,
672
+ * but the path does not exist, the child process emits an `ENOENT` error
673
+ * and exits immediately. `ENOENT` is also emitted when the command
674
+ * does not exist.
675
+ *
676
+ * Use `env` to specify environment variables that will be visible to the new
677
+ * process, the default is `process.env`.
678
+ *
679
+ * `undefined` values in `env` will be ignored.
680
+ *
681
+ * Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
682
+ * exit code:
683
+ *
684
+ * ```js
685
+ * const { spawn } = require('child_process');
686
+ * const ls = spawn('ls', ['-lh', '/usr']);
687
+ *
688
+ * ls.stdout.on('data', (data) => {
689
+ * console.log(`stdout: ${data}`);
690
+ * });
691
+ *
692
+ * ls.stderr.on('data', (data) => {
693
+ * console.error(`stderr: ${data}`);
694
+ * });
695
+ *
696
+ * ls.on('close', (code) => {
697
+ * console.log(`child process exited with code ${code}`);
698
+ * });
699
+ * ```
700
+ *
701
+ * Example: A very elaborate way to run `ps ax | grep ssh`
702
+ *
703
+ * ```js
704
+ * const { spawn } = require('child_process');
705
+ * const ps = spawn('ps', ['ax']);
706
+ * const grep = spawn('grep', ['ssh']);
707
+ *
708
+ * ps.stdout.on('data', (data) => {
709
+ * grep.stdin.write(data);
710
+ * });
711
+ *
712
+ * ps.stderr.on('data', (data) => {
713
+ * console.error(`ps stderr: ${data}`);
714
+ * });
715
+ *
716
+ * ps.on('close', (code) => {
717
+ * if (code !== 0) {
718
+ * console.log(`ps process exited with code ${code}`);
719
+ * }
720
+ * grep.stdin.end();
721
+ * });
722
+ *
723
+ * grep.stdout.on('data', (data) => {
724
+ * console.log(data.toString());
725
+ * });
726
+ *
727
+ * grep.stderr.on('data', (data) => {
728
+ * console.error(`grep stderr: ${data}`);
729
+ * });
730
+ *
731
+ * grep.on('close', (code) => {
732
+ * if (code !== 0) {
733
+ * console.log(`grep process exited with code ${code}`);
734
+ * }
735
+ * });
736
+ * ```
737
+ *
738
+ * Example of checking for failed `spawn`:
739
+ *
740
+ * ```js
741
+ * const { spawn } = require('child_process');
742
+ * const subprocess = spawn('bad_command');
743
+ *
744
+ * subprocess.on('error', (err) => {
745
+ * console.error('Failed to start subprocess.');
746
+ * });
747
+ * ```
748
+ *
749
+ * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
750
+ * title while others (Windows, SunOS) will use `command`.
751
+ *
752
+ * Node.js currently overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent,
753
+ * retrieve it with the`process.argv0` property instead.
754
+ *
755
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
756
+ * the error passed to the callback will be an `AbortError`:
757
+ *
758
+ * ```js
759
+ * const { spawn } = require('child_process');
760
+ * const controller = new AbortController();
761
+ * const { signal } = controller;
762
+ * const grep = spawn('grep', ['ssh'], { signal });
763
+ * grep.on('error', (err) => {
764
+ * // This will be called with err being an AbortError if the controller aborts
765
+ * });
766
+ * controller.abort(); // Stops the child process
767
+ * ```
768
+ * @since v0.1.90
769
+ * @param command The command to run.
770
+ * @param args List of string arguments.
771
+ */
198
772
  function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
199
-
200
- function spawn(
201
- command: string,
202
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
203
- ): ChildProcessByStdio<Writable, Readable, Readable>;
204
- function spawn(
205
- command: string,
206
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
207
- ): ChildProcessByStdio<Writable, Readable, null>;
208
- function spawn(
209
- command: string,
210
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
211
- ): ChildProcessByStdio<Writable, null, Readable>;
212
- function spawn(
213
- command: string,
214
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
215
- ): ChildProcessByStdio<null, Readable, Readable>;
216
- function spawn(
217
- command: string,
218
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
219
- ): ChildProcessByStdio<Writable, null, null>;
220
- function spawn(
221
- command: string,
222
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
223
- ): ChildProcessByStdio<null, Readable, null>;
224
- function spawn(
225
- command: string,
226
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
227
- ): ChildProcessByStdio<null, null, Readable>;
228
- function spawn(
229
- command: string,
230
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
231
- ): ChildProcessByStdio<null, null, null>;
232
-
773
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): ChildProcessByStdio<Writable, Readable, Readable>;
774
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): ChildProcessByStdio<Writable, Readable, null>;
775
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): ChildProcessByStdio<Writable, null, Readable>;
776
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): ChildProcessByStdio<null, Readable, Readable>;
777
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): ChildProcessByStdio<Writable, null, null>;
778
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): ChildProcessByStdio<null, Readable, null>;
779
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): ChildProcessByStdio<null, null, Readable>;
780
+ function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): ChildProcessByStdio<null, null, null>;
233
781
  function spawn(command: string, options: SpawnOptions): ChildProcess;
234
-
235
782
  // overloads of spawn with 'args'
236
783
  function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
237
-
238
- function spawn(
239
- command: string,
240
- args: ReadonlyArray<string>,
241
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
242
- ): ChildProcessByStdio<Writable, Readable, Readable>;
243
- function spawn(
244
- command: string,
245
- args: ReadonlyArray<string>,
246
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
247
- ): ChildProcessByStdio<Writable, Readable, null>;
248
- function spawn(
249
- command: string,
250
- args: ReadonlyArray<string>,
251
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
252
- ): ChildProcessByStdio<Writable, null, Readable>;
253
- function spawn(
254
- command: string,
255
- args: ReadonlyArray<string>,
256
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
257
- ): ChildProcessByStdio<null, Readable, Readable>;
258
- function spawn(
259
- command: string,
260
- args: ReadonlyArray<string>,
261
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
262
- ): ChildProcessByStdio<Writable, null, null>;
263
- function spawn(
264
- command: string,
265
- args: ReadonlyArray<string>,
266
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
267
- ): ChildProcessByStdio<null, Readable, null>;
268
- function spawn(
269
- command: string,
270
- args: ReadonlyArray<string>,
271
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
272
- ): ChildProcessByStdio<null, null, Readable>;
273
- function spawn(
274
- command: string,
275
- args: ReadonlyArray<string>,
276
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
277
- ): ChildProcessByStdio<null, null, null>;
278
-
784
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): ChildProcessByStdio<Writable, Readable, Readable>;
785
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): ChildProcessByStdio<Writable, Readable, null>;
786
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): ChildProcessByStdio<Writable, null, Readable>;
787
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): ChildProcessByStdio<null, Readable, Readable>;
788
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): ChildProcessByStdio<Writable, null, null>;
789
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): ChildProcessByStdio<null, Readable, null>;
790
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): ChildProcessByStdio<null, null, Readable>;
791
+ function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): ChildProcessByStdio<null, null, null>;
279
792
  function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptions): ChildProcess;
280
-
281
793
  interface ExecOptions extends CommonOptions {
282
- shell?: string;
283
- maxBuffer?: number;
284
- killSignal?: NodeJS.Signals | number;
794
+ shell?: string | undefined;
795
+ signal?: AbortSignal | undefined;
796
+ maxBuffer?: number | undefined;
797
+ killSignal?: NodeJS.Signals | number | undefined;
285
798
  }
286
-
287
799
  interface ExecOptionsWithStringEncoding extends ExecOptions {
288
800
  encoding: BufferEncoding;
289
801
  }
290
-
291
802
  interface ExecOptionsWithBufferEncoding extends ExecOptions {
292
803
  encoding: BufferEncoding | null; // specify `null`.
293
804
  }
294
-
295
805
  interface ExecException extends Error {
296
- cmd?: string;
297
- killed?: boolean;
298
- code?: number;
299
- signal?: NodeJS.Signals;
806
+ cmd?: string | undefined;
807
+ killed?: boolean | undefined;
808
+ code?: number | undefined;
809
+ signal?: NodeJS.Signals | undefined;
300
810
  }
301
-
302
- // no `options` definitely means stdout/stderr are `string`.
811
+ /**
812
+ * Spawns a shell then executes the `command` within that shell, buffering any
813
+ * generated output. The `command` string passed to the exec function is processed
814
+ * directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters))
815
+ * need to be dealt with accordingly:
816
+ *
817
+ * ```js
818
+ * const { exec } = require('child_process');
819
+ *
820
+ * exec('"/path/to/test file/test.sh" arg1 arg2');
821
+ * // Double quotes are used so that the space in the path is not interpreted as
822
+ * // a delimiter of multiple arguments.
823
+ *
824
+ * exec('echo "The \\$HOME variable is $HOME"');
825
+ * // The $HOME variable is escaped in the first instance, but not in the second.
826
+ * ```
827
+ *
828
+ * **Never pass unsanitized user input to this function. Any input containing shell**
829
+ * **metacharacters may be used to trigger arbitrary command execution.**
830
+ *
831
+ * If a `callback` function is provided, it is called with the arguments`(error, stdout, stderr)`. On success, `error` will be `null`. On error,`error` will be an instance of `Error`. The
832
+ * `error.code` property will be
833
+ * the exit code of the process. By convention, any exit code other than `0`indicates an error. `error.signal` will be the signal that terminated the
834
+ * process.
835
+ *
836
+ * The `stdout` and `stderr` arguments passed to the callback will contain the
837
+ * stdout and stderr output of the child process. By default, Node.js will decode
838
+ * the output as UTF-8 and pass strings to the callback. The `encoding` option
839
+ * can be used to specify the character encoding used to decode the stdout and
840
+ * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
841
+ * encoding, `Buffer` objects will be passed to the callback instead.
842
+ *
843
+ * ```js
844
+ * const { exec } = require('child_process');
845
+ * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
846
+ * if (error) {
847
+ * console.error(`exec error: ${error}`);
848
+ * return;
849
+ * }
850
+ * console.log(`stdout: ${stdout}`);
851
+ * console.error(`stderr: ${stderr}`);
852
+ * });
853
+ * ```
854
+ *
855
+ * If `timeout` is greater than `0`, the parent will send the signal
856
+ * identified by the `killSignal` property (the default is `'SIGTERM'`) if the
857
+ * child runs longer than `timeout` milliseconds.
858
+ *
859
+ * Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace
860
+ * the existing process and uses a shell to execute the command.
861
+ *
862
+ * If this method is invoked as its `util.promisify()` ed version, it returns
863
+ * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
864
+ * case of an error (including any error resulting in an exit code other than 0), a
865
+ * rejected promise is returned, with the same `error` object given in the
866
+ * callback, but with two additional properties `stdout` and `stderr`.
867
+ *
868
+ * ```js
869
+ * const util = require('util');
870
+ * const exec = util.promisify(require('child_process').exec);
871
+ *
872
+ * async function lsExample() {
873
+ * const { stdout, stderr } = await exec('ls');
874
+ * console.log('stdout:', stdout);
875
+ * console.error('stderr:', stderr);
876
+ * }
877
+ * lsExample();
878
+ * ```
879
+ *
880
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
881
+ * the error passed to the callback will be an `AbortError`:
882
+ *
883
+ * ```js
884
+ * const { exec } = require('child_process');
885
+ * const controller = new AbortController();
886
+ * const { signal } = controller;
887
+ * const child = exec('grep ssh', { signal }, (error) => {
888
+ * console.log(error); // an AbortError
889
+ * });
890
+ * controller.abort();
891
+ * ```
892
+ * @since v0.1.90
893
+ * @param command The command to run, with space-separated arguments.
894
+ * @param callback called with the output when process terminates.
895
+ */
303
896
  function exec(command: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
304
-
305
897
  // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
306
- function exec(command: string, options: { encoding: "buffer" | null } & ExecOptions, callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
307
-
898
+ function exec(
899
+ command: string,
900
+ options: {
901
+ encoding: 'buffer' | null;
902
+ } & ExecOptions,
903
+ callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void
904
+ ): ChildProcess;
308
905
  // `options` with well known `encoding` means stdout/stderr are definitely `string`.
309
- function exec(command: string, options: { encoding: BufferEncoding } & ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
310
-
906
+ function exec(
907
+ command: string,
908
+ options: {
909
+ encoding: BufferEncoding;
910
+ } & ExecOptions,
911
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void
912
+ ): ChildProcess;
311
913
  // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
312
914
  // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
313
915
  function exec(
314
916
  command: string,
315
- options: { encoding: BufferEncoding } & ExecOptions,
316
- callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
917
+ options: {
918
+ encoding: BufferEncoding;
919
+ } & ExecOptions,
920
+ callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void
317
921
  ): ChildProcess;
318
-
319
922
  // `options` without an `encoding` means stdout/stderr are definitely `string`.
320
923
  function exec(command: string, options: ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
321
-
322
924
  // fallback if nothing else matches. Worst case is always `string | Buffer`.
323
925
  function exec(
324
926
  command: string,
325
- options: (BaseEncodingOptions & ExecOptions) | undefined | null,
326
- callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
927
+ options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
928
+ callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void
327
929
  ): ChildProcess;
328
-
329
930
  interface PromiseWithChild<T> extends Promise<T> {
330
931
  child: ChildProcess;
331
932
  }
332
-
333
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
334
933
  namespace exec {
335
- function __promisify__(command: string): PromiseWithChild<{ stdout: string, stderr: string }>;
336
- function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
337
- function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
338
- function __promisify__(command: string, options: ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
339
- function __promisify__(command: string, options?: (BaseEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
934
+ function __promisify__(command: string): PromiseWithChild<{
935
+ stdout: string;
936
+ stderr: string;
937
+ }>;
938
+ function __promisify__(
939
+ command: string,
940
+ options: {
941
+ encoding: 'buffer' | null;
942
+ } & ExecOptions
943
+ ): PromiseWithChild<{
944
+ stdout: Buffer;
945
+ stderr: Buffer;
946
+ }>;
947
+ function __promisify__(
948
+ command: string,
949
+ options: {
950
+ encoding: BufferEncoding;
951
+ } & ExecOptions
952
+ ): PromiseWithChild<{
953
+ stdout: string;
954
+ stderr: string;
955
+ }>;
956
+ function __promisify__(
957
+ command: string,
958
+ options: ExecOptions
959
+ ): PromiseWithChild<{
960
+ stdout: string;
961
+ stderr: string;
962
+ }>;
963
+ function __promisify__(
964
+ command: string,
965
+ options?: (ObjectEncodingOptions & ExecOptions) | null
966
+ ): PromiseWithChild<{
967
+ stdout: string | Buffer;
968
+ stderr: string | Buffer;
969
+ }>;
340
970
  }
341
-
342
971
  interface ExecFileOptions extends CommonOptions, Abortable {
343
- maxBuffer?: number;
344
- killSignal?: NodeJS.Signals | number;
345
- windowsVerbatimArguments?: boolean;
346
- shell?: boolean | string;
347
- signal?: AbortSignal;
972
+ maxBuffer?: number | undefined;
973
+ killSignal?: NodeJS.Signals | number | undefined;
974
+ windowsVerbatimArguments?: boolean | undefined;
975
+ shell?: boolean | string | undefined;
976
+ signal?: AbortSignal | undefined;
348
977
  }
349
978
  interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
350
979
  encoding: BufferEncoding;
@@ -356,48 +985,101 @@ declare module 'child_process' {
356
985
  encoding: BufferEncoding;
357
986
  }
358
987
  type ExecFileException = ExecException & NodeJS.ErrnoException;
359
-
988
+ /**
989
+ * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
990
+ * executable `file` is spawned directly as a new process making it slightly more
991
+ * efficient than {@link exec}.
992
+ *
993
+ * The same options as {@link exec} are supported. Since a shell is
994
+ * not spawned, behaviors such as I/O redirection and file globbing are not
995
+ * supported.
996
+ *
997
+ * ```js
998
+ * const { execFile } = require('child_process');
999
+ * const child = execFile('node', ['--version'], (error, stdout, stderr) => {
1000
+ * if (error) {
1001
+ * throw error;
1002
+ * }
1003
+ * console.log(stdout);
1004
+ * });
1005
+ * ```
1006
+ *
1007
+ * The `stdout` and `stderr` arguments passed to the callback will contain the
1008
+ * stdout and stderr output of the child process. By default, Node.js will decode
1009
+ * the output as UTF-8 and pass strings to the callback. The `encoding` option
1010
+ * can be used to specify the character encoding used to decode the stdout and
1011
+ * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
1012
+ * encoding, `Buffer` objects will be passed to the callback instead.
1013
+ *
1014
+ * If this method is invoked as its `util.promisify()` ed version, it returns
1015
+ * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
1016
+ * case of an error (including any error resulting in an exit code other than 0), a
1017
+ * rejected promise is returned, with the same `error` object given in the
1018
+ * callback, but with two additional properties `stdout` and `stderr`.
1019
+ *
1020
+ * ```js
1021
+ * const util = require('util');
1022
+ * const execFile = util.promisify(require('child_process').execFile);
1023
+ * async function getVersion() {
1024
+ * const { stdout } = await execFile('node', ['--version']);
1025
+ * console.log(stdout);
1026
+ * }
1027
+ * getVersion();
1028
+ * ```
1029
+ *
1030
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1031
+ * **function. Any input containing shell metacharacters may be used to trigger**
1032
+ * **arbitrary command execution.**
1033
+ *
1034
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
1035
+ * the error passed to the callback will be an `AbortError`:
1036
+ *
1037
+ * ```js
1038
+ * const { execFile } = require('child_process');
1039
+ * const controller = new AbortController();
1040
+ * const { signal } = controller;
1041
+ * const child = execFile('node', ['--version'], { signal }, (error) => {
1042
+ * console.log(error); // an AbortError
1043
+ * });
1044
+ * controller.abort();
1045
+ * ```
1046
+ * @since v0.1.91
1047
+ * @param file The name or path of the executable file to run.
1048
+ * @param args List of string arguments.
1049
+ * @param callback Called with the output when process terminates.
1050
+ */
360
1051
  function execFile(file: string): ChildProcess;
361
- function execFile(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
1052
+ function execFile(file: string, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
362
1053
  function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
363
- function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
364
-
1054
+ function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
365
1055
  // no `options` definitely means stdout/stderr are `string`.
366
1056
  function execFile(file: string, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
367
1057
  function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
368
-
369
1058
  // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
370
1059
  function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
371
1060
  function execFile(
372
1061
  file: string,
373
1062
  args: ReadonlyArray<string> | undefined | null,
374
1063
  options: ExecFileOptionsWithBufferEncoding,
375
- callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
1064
+ callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void
376
1065
  ): ChildProcess;
377
-
378
1066
  // `options` with well known `encoding` means stdout/stderr are definitely `string`.
379
1067
  function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
380
1068
  function execFile(
381
1069
  file: string,
382
1070
  args: ReadonlyArray<string> | undefined | null,
383
1071
  options: ExecFileOptionsWithStringEncoding,
384
- callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
1072
+ callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
385
1073
  ): ChildProcess;
386
-
387
1074
  // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
388
1075
  // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
389
- function execFile(
390
- file: string,
391
- options: ExecFileOptionsWithOtherEncoding,
392
- callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
393
- ): ChildProcess;
1076
+ function execFile(file: string, options: ExecFileOptionsWithOtherEncoding, callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
394
1077
  function execFile(
395
1078
  file: string,
396
1079
  args: ReadonlyArray<string> | undefined | null,
397
1080
  options: ExecFileOptionsWithOtherEncoding,
398
- callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
1081
+ callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void
399
1082
  ): ChildProcess;
400
-
401
1083
  // `options` without an `encoding` means stdout/stderr are definitely `string`.
402
1084
  function execFile(file: string, options: ExecFileOptions, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
403
1085
  function execFile(
@@ -406,121 +1088,282 @@ declare module 'child_process' {
406
1088
  options: ExecFileOptions,
407
1089
  callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
408
1090
  ): ChildProcess;
409
-
410
1091
  // fallback if nothing else matches. Worst case is always `string | Buffer`.
411
1092
  function execFile(
412
1093
  file: string,
413
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
414
- callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
1094
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1095
+ callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null
415
1096
  ): ChildProcess;
416
1097
  function execFile(
417
1098
  file: string,
418
1099
  args: ReadonlyArray<string> | undefined | null,
419
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
420
- callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
1100
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1101
+ callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null
421
1102
  ): ChildProcess;
422
-
423
- // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
424
1103
  namespace execFile {
425
- function __promisify__(file: string): PromiseWithChild<{ stdout: string, stderr: string }>;
426
- function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null): PromiseWithChild<{ stdout: string, stderr: string }>;
427
- function __promisify__(file: string, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
428
- function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptionsWithBufferEncoding): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
429
- function __promisify__(file: string, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
430
- function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptionsWithStringEncoding): PromiseWithChild<{ stdout: string, stderr: string }>;
431
- function __promisify__(file: string, options: ExecFileOptionsWithOtherEncoding): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
1104
+ function __promisify__(file: string): PromiseWithChild<{
1105
+ stdout: string;
1106
+ stderr: string;
1107
+ }>;
1108
+ function __promisify__(
1109
+ file: string,
1110
+ args: ReadonlyArray<string> | undefined | null
1111
+ ): PromiseWithChild<{
1112
+ stdout: string;
1113
+ stderr: string;
1114
+ }>;
1115
+ function __promisify__(
1116
+ file: string,
1117
+ options: ExecFileOptionsWithBufferEncoding
1118
+ ): PromiseWithChild<{
1119
+ stdout: Buffer;
1120
+ stderr: Buffer;
1121
+ }>;
1122
+ function __promisify__(
1123
+ file: string,
1124
+ args: ReadonlyArray<string> | undefined | null,
1125
+ options: ExecFileOptionsWithBufferEncoding
1126
+ ): PromiseWithChild<{
1127
+ stdout: Buffer;
1128
+ stderr: Buffer;
1129
+ }>;
1130
+ function __promisify__(
1131
+ file: string,
1132
+ options: ExecFileOptionsWithStringEncoding
1133
+ ): PromiseWithChild<{
1134
+ stdout: string;
1135
+ stderr: string;
1136
+ }>;
432
1137
  function __promisify__(
433
1138
  file: string,
434
1139
  args: ReadonlyArray<string> | undefined | null,
435
- options: ExecFileOptionsWithOtherEncoding,
436
- ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
437
- function __promisify__(file: string, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
438
- function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
439
- function __promisify__(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
1140
+ options: ExecFileOptionsWithStringEncoding
1141
+ ): PromiseWithChild<{
1142
+ stdout: string;
1143
+ stderr: string;
1144
+ }>;
1145
+ function __promisify__(
1146
+ file: string,
1147
+ options: ExecFileOptionsWithOtherEncoding
1148
+ ): PromiseWithChild<{
1149
+ stdout: string | Buffer;
1150
+ stderr: string | Buffer;
1151
+ }>;
440
1152
  function __promisify__(
441
1153
  file: string,
442
1154
  args: ReadonlyArray<string> | undefined | null,
443
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
444
- ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
1155
+ options: ExecFileOptionsWithOtherEncoding
1156
+ ): PromiseWithChild<{
1157
+ stdout: string | Buffer;
1158
+ stderr: string | Buffer;
1159
+ }>;
1160
+ function __promisify__(
1161
+ file: string,
1162
+ options: ExecFileOptions
1163
+ ): PromiseWithChild<{
1164
+ stdout: string;
1165
+ stderr: string;
1166
+ }>;
1167
+ function __promisify__(
1168
+ file: string,
1169
+ args: ReadonlyArray<string> | undefined | null,
1170
+ options: ExecFileOptions
1171
+ ): PromiseWithChild<{
1172
+ stdout: string;
1173
+ stderr: string;
1174
+ }>;
1175
+ function __promisify__(
1176
+ file: string,
1177
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null
1178
+ ): PromiseWithChild<{
1179
+ stdout: string | Buffer;
1180
+ stderr: string | Buffer;
1181
+ }>;
1182
+ function __promisify__(
1183
+ file: string,
1184
+ args: ReadonlyArray<string> | undefined | null,
1185
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null
1186
+ ): PromiseWithChild<{
1187
+ stdout: string | Buffer;
1188
+ stderr: string | Buffer;
1189
+ }>;
445
1190
  }
446
-
447
1191
  interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
448
- execPath?: string;
449
- execArgv?: string[];
450
- silent?: boolean;
451
- stdio?: StdioOptions;
452
- detached?: boolean;
453
- windowsVerbatimArguments?: boolean;
1192
+ execPath?: string | undefined;
1193
+ execArgv?: string[] | undefined;
1194
+ silent?: boolean | undefined;
1195
+ stdio?: StdioOptions | undefined;
1196
+ detached?: boolean | undefined;
1197
+ windowsVerbatimArguments?: boolean | undefined;
454
1198
  }
1199
+ /**
1200
+ * The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes.
1201
+ * Like {@link spawn}, a `ChildProcess` object is returned. The
1202
+ * returned `ChildProcess` will have an additional communication channel
1203
+ * built-in that allows messages to be passed back and forth between the parent and
1204
+ * child. See `subprocess.send()` for details.
1205
+ *
1206
+ * Keep in mind that spawned Node.js child processes are
1207
+ * independent of the parent with exception of the IPC communication channel
1208
+ * that is established between the two. Each process has its own memory, with
1209
+ * their own V8 instances. Because of the additional resource allocations
1210
+ * required, spawning a large number of child Node.js processes is not
1211
+ * recommended.
1212
+ *
1213
+ * By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the`options` object allows for an alternative
1214
+ * execution path to be used.
1215
+ *
1216
+ * Node.js processes launched with a custom `execPath` will communicate with the
1217
+ * parent process using the file descriptor (fd) identified using the
1218
+ * environment variable `NODE_CHANNEL_FD` on the child process.
1219
+ *
1220
+ * Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
1221
+ * current process.
1222
+ *
1223
+ * The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set.
1224
+ *
1225
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
1226
+ * the error passed to the callback will be an `AbortError`:
1227
+ *
1228
+ * ```js
1229
+ * if (process.argv[2] === 'child') {
1230
+ * setTimeout(() => {
1231
+ * console.log(`Hello from ${process.argv[2]}!`);
1232
+ * }, 1_000);
1233
+ * } else {
1234
+ * const { fork } = require('child_process');
1235
+ * const controller = new AbortController();
1236
+ * const { signal } = controller;
1237
+ * const child = fork(__filename, ['child'], { signal });
1238
+ * child.on('error', (err) => {
1239
+ * // This will be called with err being an AbortError if the controller aborts
1240
+ * });
1241
+ * controller.abort(); // Stops the child process
1242
+ * }
1243
+ * ```
1244
+ * @since v0.5.0
1245
+ * @param modulePath The module to run in the child.
1246
+ * @param args List of string arguments.
1247
+ */
455
1248
  function fork(modulePath: string, options?: ForkOptions): ChildProcess;
456
1249
  function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
457
-
458
1250
  interface SpawnSyncOptions extends CommonSpawnOptions {
459
- input?: string | NodeJS.ArrayBufferView;
460
- maxBuffer?: number;
461
- encoding?: BufferEncoding | 'buffer' | null;
1251
+ input?: string | NodeJS.ArrayBufferView | undefined;
1252
+ maxBuffer?: number | undefined;
1253
+ encoding?: BufferEncoding | 'buffer' | null | undefined;
462
1254
  }
463
1255
  interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
464
1256
  encoding: BufferEncoding;
465
1257
  }
466
1258
  interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
467
- encoding?: 'buffer' | null;
1259
+ encoding?: 'buffer' | null | undefined;
468
1260
  }
469
1261
  interface SpawnSyncReturns<T> {
470
1262
  pid: number;
471
- output: string[];
1263
+ output: Array<T | null>;
472
1264
  stdout: T;
473
1265
  stderr: T;
474
1266
  status: number | null;
475
1267
  signal: NodeJS.Signals | null;
476
- error?: Error;
1268
+ error?: Error | undefined;
477
1269
  }
1270
+ /**
1271
+ * The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
1272
+ * until the child process has fully closed. When a timeout has been encountered
1273
+ * and `killSignal` is sent, the method won't return until the process has
1274
+ * completely exited. If the process intercepts and handles the `SIGTERM` signal
1275
+ * and doesn't exit, the parent process will wait until the child process has
1276
+ * exited.
1277
+ *
1278
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1279
+ * **function. Any input containing shell metacharacters may be used to trigger**
1280
+ * **arbitrary command execution.**
1281
+ * @since v0.11.12
1282
+ * @param command The command to run.
1283
+ * @param args List of string arguments.
1284
+ */
478
1285
  function spawnSync(command: string): SpawnSyncReturns<Buffer>;
479
- function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
480
- function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
481
- function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
482
- function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
483
- function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
484
- function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
485
-
486
- interface ExecSyncOptions extends CommonOptions {
487
- input?: string | Uint8Array;
488
- stdio?: StdioOptions;
489
- shell?: string;
490
- killSignal?: NodeJS.Signals | number;
491
- maxBuffer?: number;
492
- encoding?: BufferEncoding | 'buffer' | null;
1286
+ function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
1287
+ function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
1288
+ function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
1289
+ function spawnSync(command: string, args: ReadonlyArray<string>): SpawnSyncReturns<Buffer>;
1290
+ function spawnSync(command: string, args: ReadonlyArray<string>, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
1291
+ function spawnSync(command: string, args: ReadonlyArray<string>, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
1292
+ function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
1293
+ interface CommonExecOptions extends CommonOptions {
1294
+ input?: string | NodeJS.ArrayBufferView | undefined;
1295
+ stdio?: StdioOptions | undefined;
1296
+ killSignal?: NodeJS.Signals | number | undefined;
1297
+ maxBuffer?: number | undefined;
1298
+ encoding?: BufferEncoding | 'buffer' | null | undefined;
1299
+ }
1300
+ interface ExecSyncOptions extends CommonExecOptions {
1301
+ shell?: string | undefined;
493
1302
  }
494
1303
  interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
495
1304
  encoding: BufferEncoding;
496
1305
  }
497
1306
  interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
498
- encoding?: 'buffer' | null;
1307
+ encoding?: 'buffer' | null | undefined;
499
1308
  }
1309
+ /**
1310
+ * The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return
1311
+ * until the child process has fully closed. When a timeout has been encountered
1312
+ * and `killSignal` is sent, the method won't return until the process has
1313
+ * completely exited. If the child process intercepts and handles the `SIGTERM`signal and doesn't exit, the parent process will wait until the child process
1314
+ * has exited.
1315
+ *
1316
+ * If the process times out or has a non-zero exit code, this method will throw.
1317
+ * The `Error` object will contain the entire result from {@link spawnSync}.
1318
+ *
1319
+ * **Never pass unsanitized user input to this function. Any input containing shell**
1320
+ * **metacharacters may be used to trigger arbitrary command execution.**
1321
+ * @since v0.11.12
1322
+ * @param command The command to run.
1323
+ * @return The stdout from the command.
1324
+ */
500
1325
  function execSync(command: string): Buffer;
501
- function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
502
- function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
503
- function execSync(command: string, options?: ExecSyncOptions): Buffer;
504
-
505
- interface ExecFileSyncOptions extends CommonOptions {
506
- input?: string | NodeJS.ArrayBufferView;
507
- stdio?: StdioOptions;
508
- killSignal?: NodeJS.Signals | number;
509
- maxBuffer?: number;
510
- encoding?: BufferEncoding;
511
- shell?: boolean | string;
1326
+ function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string;
1327
+ function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer;
1328
+ function execSync(command: string, options?: ExecSyncOptions): string | Buffer;
1329
+ interface ExecFileSyncOptions extends CommonExecOptions {
1330
+ shell?: boolean | string | undefined;
512
1331
  }
513
1332
  interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
514
1333
  encoding: BufferEncoding;
515
1334
  }
516
1335
  interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
517
- encoding: BufferEncoding; // specify `null`.
518
- }
519
- function execFileSync(command: string): Buffer;
520
- function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
521
- function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
522
- function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
523
- function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithStringEncoding): string;
524
- function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
525
- function execFileSync(command: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): Buffer;
1336
+ encoding?: 'buffer' | null; // specify `null`.
1337
+ }
1338
+ /**
1339
+ * The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not
1340
+ * return until the child process has fully closed. When a timeout has been
1341
+ * encountered and `killSignal` is sent, the method won't return until the process
1342
+ * has completely exited.
1343
+ *
1344
+ * If the child process intercepts and handles the `SIGTERM` signal and
1345
+ * does not exit, the parent process will still wait until the child process has
1346
+ * exited.
1347
+ *
1348
+ * If the process times out or has a non-zero exit code, this method will throw an `Error` that will include the full result of the underlying {@link spawnSync}.
1349
+ *
1350
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1351
+ * **function. Any input containing shell metacharacters may be used to trigger**
1352
+ * **arbitrary command execution.**
1353
+ * @since v0.11.12
1354
+ * @param file The name or path of the executable file to run.
1355
+ * @param args List of string arguments.
1356
+ * @return The stdout from the command.
1357
+ */
1358
+ function execFileSync(file: string): Buffer;
1359
+ function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string;
1360
+ function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1361
+ function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer;
1362
+ function execFileSync(file: string, args: ReadonlyArray<string>): Buffer;
1363
+ function execFileSync(file: string, args: ReadonlyArray<string>, options: ExecFileSyncOptionsWithStringEncoding): string;
1364
+ function execFileSync(file: string, args: ReadonlyArray<string>, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1365
+ function execFileSync(file: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): string | Buffer;
1366
+ }
1367
+ declare module 'node:child_process' {
1368
+ export * from 'child_process';
526
1369
  }