@node-red/editor-client 3.1.8 → 4.0.0-beta.2

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