rahad-all-downloader 2.1.16 → 2.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. package/.github/workflows/Run.yml +20 -0
  2. package/README.md +0 -1
  3. package/index.js +1 -1
  4. package/package.json +4 -2
  5. package/.cache/nix/binary-cache-v6.sqlite +0 -0
  6. package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
  7. package/.cache/replit/env/latest +0 -123
  8. package/.cache/replit/env/latest.json +0 -1
  9. package/.cache/replit/modules/nix.res +0 -1
  10. package/.cache/replit/modules/nodejs-20.res +0 -1
  11. package/.cache/replit/modules/replit.res +0 -1
  12. package/.cache/replit/modules.stamp +0 -0
  13. package/.cache/replit/nix/env.json +0 -1
  14. package/.cache/typescript/5.4/node_modules/.package-lock.json +0 -137
  15. package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +0 -21
  16. package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +0 -48
  17. package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +0 -29
  18. package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +0 -35
  19. package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +0 -21
  20. package/.cache/typescript/5.4/node_modules/@types/node/README.md +0 -15
  21. package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +0 -8
  22. package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +0 -1040
  23. package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +0 -541
  24. package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +0 -2363
  25. package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +0 -1544
  26. package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +0 -578
  27. package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +0 -452
  28. package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +0 -19
  29. package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +0 -4523
  30. package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +0 -596
  31. package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
  32. package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +0 -474
  33. package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +0 -864
  34. package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +0 -124
  35. package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +0 -170
  36. package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +0 -909
  37. package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +0 -1245
  38. package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +0 -4317
  39. package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +0 -411
  40. package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +0 -1
  41. package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +0 -1908
  42. package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +0 -2418
  43. package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +0 -550
  44. package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +0 -89
  45. package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +0 -2746
  46. package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +0 -315
  47. package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +0 -999
  48. package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +0 -495
  49. package/.cache/typescript/5.4/node_modules/@types/node/package.json +0 -217
  50. package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +0 -191
  51. package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +0 -905
  52. package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +0 -1754
  53. package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +0 -117
  54. package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +0 -153
  55. package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +0 -150
  56. package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +0 -540
  57. package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +0 -430
  58. package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +0 -153
  59. package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +0 -12
  60. package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +0 -83
  61. package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +0 -367
  62. package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +0 -1707
  63. package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +0 -67
  64. package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +0 -1718
  65. package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +0 -97
  66. package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +0 -240
  67. package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +0 -1217
  68. package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +0 -197
  69. package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +0 -208
  70. package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +0 -952
  71. package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +0 -2292
  72. package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +0 -808
  73. package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +0 -924
  74. package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +0 -181
  75. package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +0 -691
  76. package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +0 -530
  77. package/.cache/typescript/5.4/node_modules/@types/node-fetch/LICENSE +0 -21
  78. package/.cache/typescript/5.4/node_modules/@types/node-fetch/README.md +0 -15
  79. package/.cache/typescript/5.4/node_modules/@types/node-fetch/externals.d.ts +0 -32
  80. package/.cache/typescript/5.4/node_modules/@types/node-fetch/index.d.ts +0 -238
  81. package/.cache/typescript/5.4/node_modules/@types/node-fetch/package.json +0 -83
  82. package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +0 -21
  83. package/.cache/typescript/5.4/node_modules/@types/request/README.md +0 -15
  84. package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +0 -395
  85. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/License +0 -19
  86. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md +0 -350
  87. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md.bak +0 -350
  88. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/index.d.ts +0 -51
  89. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/browser.js +0 -2
  90. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/form_data.js +0 -483
  91. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/populate.js +0 -10
  92. package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/package.json +0 -68
  93. package/.cache/typescript/5.4/node_modules/@types/request/package.json +0 -70
  94. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +0 -21
  95. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +0 -15
  96. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +0 -321
  97. package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +0 -35
  98. package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +0 -21
  99. package/.cache/typescript/5.4/node_modules/asynckit/README.md +0 -233
  100. package/.cache/typescript/5.4/node_modules/asynckit/bench.js +0 -76
  101. package/.cache/typescript/5.4/node_modules/asynckit/index.js +0 -6
  102. package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +0 -29
  103. package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +0 -34
  104. package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +0 -26
  105. package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +0 -75
  106. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +0 -91
  107. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +0 -25
  108. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +0 -25
  109. package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
  110. package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +0 -37
  111. package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +0 -141
  112. package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +0 -29
  113. package/.cache/typescript/5.4/node_modules/asynckit/package.json +0 -63
  114. package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +0 -43
  115. package/.cache/typescript/5.4/node_modules/asynckit/serial.js +0 -17
  116. package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +0 -75
  117. package/.cache/typescript/5.4/node_modules/asynckit/stream.js +0 -21
  118. package/.cache/typescript/5.4/node_modules/combined-stream/License +0 -19
  119. package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +0 -138
  120. package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +0 -208
  121. package/.cache/typescript/5.4/node_modules/combined-stream/package.json +0 -25
  122. package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +0 -17
  123. package/.cache/typescript/5.4/node_modules/delayed-stream/License +0 -19
  124. package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +0 -7
  125. package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +0 -141
  126. package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
  127. package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +0 -27
  128. package/.cache/typescript/5.4/node_modules/form-data/License +0 -19
  129. package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +0 -358
  130. package/.cache/typescript/5.4/node_modules/form-data/Readme.md +0 -358
  131. package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +0 -62
  132. package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +0 -2
  133. package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +0 -501
  134. package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +0 -10
  135. package/.cache/typescript/5.4/node_modules/form-data/package.json +0 -68
  136. package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +0 -507
  137. package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +0 -23
  138. package/.cache/typescript/5.4/node_modules/mime-db/README.md +0 -100
  139. package/.cache/typescript/5.4/node_modules/mime-db/db.json +0 -8519
  140. package/.cache/typescript/5.4/node_modules/mime-db/index.js +0 -12
  141. package/.cache/typescript/5.4/node_modules/mime-db/package.json +0 -60
  142. package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +0 -397
  143. package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +0 -23
  144. package/.cache/typescript/5.4/node_modules/mime-types/README.md +0 -113
  145. package/.cache/typescript/5.4/node_modules/mime-types/index.js +0 -188
  146. package/.cache/typescript/5.4/node_modules/mime-types/package.json +0 -44
  147. package/.cache/typescript/5.4/node_modules/types-registry/README.md +0 -2
  148. package/.cache/typescript/5.4/node_modules/types-registry/index.json +0 -1
  149. package/.cache/typescript/5.4/node_modules/types-registry/package.json +0 -20
  150. package/.cache/typescript/5.4/node_modules/undici-types/README.md +0 -6
  151. package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +0 -31
  152. package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +0 -43
  153. package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +0 -18
  154. package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +0 -36
  155. package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +0 -97
  156. package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +0 -34
  157. package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +0 -21
  158. package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +0 -28
  159. package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
  160. package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +0 -241
  161. package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +0 -128
  162. package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +0 -209
  163. package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +0 -39
  164. package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +0 -54
  165. package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +0 -108
  166. package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  167. package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +0 -7
  168. package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +0 -9
  169. package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +0 -4
  170. package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +0 -63
  171. package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +0 -5
  172. package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +0 -50
  173. package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +0 -25
  174. package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +0 -12
  175. package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  176. package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +0 -25
  177. package/.cache/typescript/5.4/node_modules/undici-types/package.json +0 -55
  178. package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +0 -71
  179. package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +0 -19
  180. package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +0 -28
  181. package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +0 -30
  182. package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +0 -61
  183. package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +0 -220
  184. package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +0 -131
  185. package/.cache/typescript/5.4/package-lock.json +0 -146
  186. package/.cache/typescript/5.4/package.json +0 -1
  187. package/.replit +0 -21
  188. package/replit.nix +0 -3
@@ -1,1544 +0,0 @@
1
- /**
2
- * The `node: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('node: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 `node:child_process` module provides a handful of
48
- * synchronous 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/v20.13.1/lib/child_process.js)
67
- */
68
- declare module "child_process" {
69
- import { ObjectEncodingOptions } from "node:fs";
70
- import { Abortable, EventEmitter } from "node:events";
71
- import * as dgram from "node:dgram";
72
- import * as net from "node:net";
73
- import { Pipe, Readable, Stream, Writable } from "node:stream";
74
- import { URL } from "node:url";
75
- type Serializable = string | object | number | boolean | bigint;
76
- type SendHandle = net.Socket | net.Server | dgram.Socket | undefined;
77
- /**
78
- * Instances of the `ChildProcess` represent spawned child processes.
79
- *
80
- * Instances of `ChildProcess` are not intended to be created directly. Rather,
81
- * use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create
82
- * instances of `ChildProcess`.
83
- * @since v2.2.0
84
- */
85
- class ChildProcess extends EventEmitter {
86
- /**
87
- * A `Writable Stream` that represents the child process's `stdin`.
88
- *
89
- * If a child process waits to read all of its input, the child will not continue
90
- * until this stream has been closed via `end()`.
91
- *
92
- * If the child was spawned with `stdio[0]` set to anything other than `'pipe'`,
93
- * then this will be `null`.
94
- *
95
- * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
96
- * refer to the same value.
97
- *
98
- * The `subprocess.stdin` property can be `null` or `undefined` if the child process could not be successfully spawned.
99
- * @since v0.1.90
100
- */
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('node: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` or `undefined` if the child process could not be successfully spawned.
122
- * @since v0.1.90
123
- */
124
- stdout: Readable | null;
125
- /**
126
- * A `Readable Stream` that represents the child process's `stderr`.
127
- *
128
- * If the child was spawned with `stdio[2]` set to anything other than `'pipe'`,
129
- * then this will be `null`.
130
- *
131
- * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
132
- * refer to the same value.
133
- *
134
- * The `subprocess.stderr` property can be `null` or `undefined` if the child process could not be successfully spawned.
135
- * @since v0.1.90
136
- */
137
- stderr: Readable | null;
138
- /**
139
- * The `subprocess.channel` property is a reference to the child's IPC channel. If
140
- * no IPC channel exists, this property is `undefined`.
141
- * @since v7.1.0
142
- */
143
- readonly channel?: Pipe | null | undefined;
144
- /**
145
- * A sparse array of pipes to the child process, corresponding with positions in
146
- * the `stdio` option passed to {@link spawn} that have been set
147
- * 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`,
148
- * respectively.
149
- *
150
- * In the following example, only the child's fd `1` (stdout) is configured as a
151
- * pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values
152
- * in the array are `null`.
153
- *
154
- * ```js
155
- * const assert = require('node:assert');
156
- * const fs = require('node:fs');
157
- * const child_process = require('node:child_process');
158
- *
159
- * const subprocess = child_process.spawn('ls', {
160
- * stdio: [
161
- * 0, // Use parent's stdin for child.
162
- * 'pipe', // Pipe child's stdout to parent.
163
- * fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
164
- * ],
165
- * });
166
- *
167
- * assert.strictEqual(subprocess.stdio[0], null);
168
- * assert.strictEqual(subprocess.stdio[0], subprocess.stdin);
169
- *
170
- * assert(subprocess.stdout);
171
- * assert.strictEqual(subprocess.stdio[1], subprocess.stdout);
172
- *
173
- * assert.strictEqual(subprocess.stdio[2], null);
174
- * assert.strictEqual(subprocess.stdio[2], subprocess.stderr);
175
- * ```
176
- *
177
- * The `subprocess.stdio` property can be `undefined` if the child process could
178
- * not be successfully spawned.
179
- * @since v0.7.10
180
- */
181
- readonly stdio: [
182
- Writable | null,
183
- // stdin
184
- Readable | null,
185
- // stdout
186
- Readable | null,
187
- // stderr
188
- Readable | Writable | null | undefined,
189
- // extra
190
- Readable | Writable | null | undefined, // extra
191
- ];
192
- /**
193
- * The `subprocess.killed` property indicates whether the child process
194
- * successfully received a signal from `subprocess.kill()`. The `killed` property
195
- * does not indicate that the child process has been terminated.
196
- * @since v0.5.10
197
- */
198
- readonly killed: boolean;
199
- /**
200
- * Returns the process identifier (PID) of the child process. If the child process
201
- * fails to spawn due to errors, then the value is `undefined` and `error` is
202
- * emitted.
203
- *
204
- * ```js
205
- * const { spawn } = require('node:child_process');
206
- * const grep = spawn('grep', ['ssh']);
207
- *
208
- * console.log(`Spawned child pid: ${grep.pid}`);
209
- * grep.stdin.end();
210
- * ```
211
- * @since v0.1.90
212
- */
213
- readonly pid?: number | undefined;
214
- /**
215
- * The `subprocess.connected` property indicates whether it is still possible to
216
- * send and receive messages from a child process. When `subprocess.connected` is `false`, it is no longer possible to send or receive messages.
217
- * @since v0.7.2
218
- */
219
- readonly connected: boolean;
220
- /**
221
- * The `subprocess.exitCode` property indicates the exit code of the child process.
222
- * If the child process is still running, the field will be `null`.
223
- */
224
- readonly exitCode: number | null;
225
- /**
226
- * The `subprocess.signalCode` property indicates the signal received by
227
- * the child process if any, else `null`.
228
- */
229
- readonly signalCode: NodeJS.Signals | null;
230
- /**
231
- * The `subprocess.spawnargs` property represents the full list of command-line
232
- * arguments the child process was launched with.
233
- */
234
- readonly spawnargs: string[];
235
- /**
236
- * The `subprocess.spawnfile` property indicates the executable file name of
237
- * the child process that is launched.
238
- *
239
- * For {@link fork}, its value will be equal to `process.execPath`.
240
- * For {@link spawn}, its value will be the name of
241
- * the executable file.
242
- * For {@link exec}, its value will be the name of the shell
243
- * in which the child process is launched.
244
- */
245
- readonly spawnfile: string;
246
- /**
247
- * The `subprocess.kill()` method sends a signal to the child process. If no
248
- * 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
249
- * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
250
- *
251
- * ```js
252
- * const { spawn } = require('node:child_process');
253
- * const grep = spawn('grep', ['ssh']);
254
- *
255
- * grep.on('close', (code, signal) => {
256
- * console.log(
257
- * `child process terminated due to receipt of signal ${signal}`);
258
- * });
259
- *
260
- * // Send SIGHUP to process.
261
- * grep.kill('SIGHUP');
262
- * ```
263
- *
264
- * The `ChildProcess` object may emit an `'error'` event if the signal
265
- * cannot be delivered. Sending a signal to a child process that has already exited
266
- * is not an error but may have unforeseen consequences. Specifically, if the
267
- * process identifier (PID) has been reassigned to another process, the signal will
268
- * be delivered to that process instead which can have unexpected results.
269
- *
270
- * While the function is called `kill`, the signal delivered to the child process
271
- * may not actually terminate the process.
272
- *
273
- * See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
274
- *
275
- * On Windows, where POSIX signals do not exist, the `signal` argument will be
276
- * ignored, and the process will be killed forcefully and abruptly (similar to `'SIGKILL'`).
277
- * See `Signal Events` for more details.
278
- *
279
- * On Linux, child processes of child processes will not be terminated
280
- * when attempting to kill their parent. This is likely to happen when running a
281
- * new process in a shell or with the use of the `shell` option of `ChildProcess`:
282
- *
283
- * ```js
284
- * 'use strict';
285
- * const { spawn } = require('node:child_process');
286
- *
287
- * const subprocess = spawn(
288
- * 'sh',
289
- * [
290
- * '-c',
291
- * `node -e "setInterval(() => {
292
- * console.log(process.pid, 'is alive')
293
- * }, 500);"`,
294
- * ], {
295
- * stdio: ['inherit', 'inherit', 'inherit'],
296
- * },
297
- * );
298
- *
299
- * setTimeout(() => {
300
- * subprocess.kill(); // Does not terminate the Node.js process in the shell.
301
- * }, 2000);
302
- * ```
303
- * @since v0.1.90
304
- */
305
- kill(signal?: NodeJS.Signals | number): boolean;
306
- /**
307
- * Calls {@link ChildProcess.kill} with `'SIGTERM'`.
308
- * @since v20.5.0
309
- */
310
- [Symbol.dispose](): void;
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('node: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 and buffered in
357
- * the socket will not be sent to the child. Sending IPC sockets is not supported on Windows.
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('node:child_process').fork('subprocess.js');
378
- *
379
- * // Open up the server object and send the handle.
380
- * const server = require('node: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 `node:net` module, `node:dgram` module servers use exactly the same workflow with the exceptions of
405
- * listening on a `'message'` event instead of `'connection'` and using `server.bind()` instead of `server.listen()`. This is, however, only
406
- * supported on Unix platforms.
407
- *
408
- * #### Example: sending a socket object
409
- *
410
- * Similarly, the `sendHandler` argument can be used to pass the handle of a
411
- * socket to the child process. The example below spawns two children that each
412
- * handle connections with "normal" or "special" priority:
413
- *
414
- * ```js
415
- * const { fork } = require('node:child_process');
416
- * const normal = fork('subprocess.js', ['normal']);
417
- * const special = fork('subprocess.js', ['special']);
418
- *
419
- * // Open up the server and send sockets to child. Use pauseOnConnect to prevent
420
- * // the sockets from being read before they are sent to the child process.
421
- * const server = require('node:net').createServer({ pauseOnConnect: true });
422
- * server.on('connection', (socket) => {
423
- *
424
- * // If this is special priority...
425
- * if (socket.remoteAddress === '74.125.127.100') {
426
- * special.send('socket', socket);
427
- * return;
428
- * }
429
- * // This is normal priority.
430
- * normal.send('socket', socket);
431
- * });
432
- * server.listen(1337);
433
- * ```
434
- *
435
- * The `subprocess.js` would receive the socket handle as the second argument
436
- * passed to the event callback function:
437
- *
438
- * ```js
439
- * process.on('message', (m, socket) => {
440
- * if (m === 'socket') {
441
- * if (socket) {
442
- * // Check that the client socket exists.
443
- * // It is possible for the socket to be closed between the time it is
444
- * // sent and the time it is received in the child process.
445
- * socket.end(`Request handled with ${process.argv[2]} priority`);
446
- * }
447
- * }
448
- * });
449
- * ```
450
- *
451
- * Do not use `.maxConnections` on a socket that has been passed to a subprocess.
452
- * The parent cannot track when the socket is destroyed.
453
- *
454
- * Any `'message'` handlers in the subprocess should verify that `socket` exists,
455
- * as the connection may have been closed during the time it takes to send the
456
- * connection to the child.
457
- * @since v0.5.9
458
- * @param sendHandle `undefined`, or a [`net.Socket`](https://nodejs.org/docs/latest-v20.x/api/net.html#class-netsocket), [`net.Server`](https://nodejs.org/docs/latest-v20.x/api/net.html#class-netserver), or [`dgram.Socket`](https://nodejs.org/docs/latest-v20.x/api/dgram.html#class-dgramsocket) object.
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(
464
- message: Serializable,
465
- sendHandle?: SendHandle,
466
- options?: MessageOptions,
467
- callback?: (error: Error | null) => void,
468
- ): boolean;
469
- /**
470
- * Closes the IPC channel between parent and child, allowing the child to exit
471
- * gracefully once there are no other connections keeping it alive. After calling
472
- * this method the `subprocess.connected` and `process.connected` properties in
473
- * both the parent and child (respectively) will be set to `false`, and it will be
474
- * no longer possible to pass messages between the processes.
475
- *
476
- * The `'disconnect'` event will be emitted when there are no messages in the
477
- * process of being received. This will most often be triggered immediately after
478
- * calling `subprocess.disconnect()`.
479
- *
480
- * When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked
481
- * within the child process to close the IPC channel as well.
482
- * @since v0.7.2
483
- */
484
- disconnect(): void;
485
- /**
486
- * By default, the parent will wait for the detached child to exit. To prevent the
487
- * 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
488
- * include the child in its reference count, allowing the parent to exit
489
- * independently of the child, unless there is an established IPC channel between
490
- * the child and the parent.
491
- *
492
- * ```js
493
- * const { spawn } = require('node:child_process');
494
- *
495
- * const subprocess = spawn(process.argv[0], ['child_program.js'], {
496
- * detached: true,
497
- * stdio: 'ignore',
498
- * });
499
- *
500
- * subprocess.unref();
501
- * ```
502
- * @since v0.7.10
503
- */
504
- unref(): void;
505
- /**
506
- * Calling `subprocess.ref()` after making a call to `subprocess.unref()` will
507
- * restore the removed reference count for the child process, forcing the parent
508
- * to wait for the child to exit before exiting itself.
509
- *
510
- * ```js
511
- * const { spawn } = require('node:child_process');
512
- *
513
- * const subprocess = spawn(process.argv[0], ['child_program.js'], {
514
- * detached: true,
515
- * stdio: 'ignore',
516
- * });
517
- *
518
- * subprocess.unref();
519
- * subprocess.ref();
520
- * ```
521
- * @since v0.7.10
522
- */
523
- ref(): void;
524
- /**
525
- * events.EventEmitter
526
- * 1. close
527
- * 2. disconnect
528
- * 3. error
529
- * 4. exit
530
- * 5. message
531
- * 6. spawn
532
- */
533
- addListener(event: string, listener: (...args: any[]) => void): this;
534
- addListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
535
- addListener(event: "disconnect", listener: () => void): this;
536
- addListener(event: "error", listener: (err: Error) => void): this;
537
- addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
538
- addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
539
- addListener(event: "spawn", listener: () => void): this;
540
- emit(event: string | symbol, ...args: any[]): boolean;
541
- emit(event: "close", code: number | null, signal: NodeJS.Signals | null): boolean;
542
- emit(event: "disconnect"): boolean;
543
- emit(event: "error", err: Error): boolean;
544
- emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean;
545
- emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean;
546
- emit(event: "spawn", listener: () => void): boolean;
547
- on(event: string, listener: (...args: any[]) => void): this;
548
- on(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
549
- on(event: "disconnect", listener: () => void): this;
550
- on(event: "error", listener: (err: Error) => void): this;
551
- on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
552
- on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
553
- on(event: "spawn", listener: () => void): this;
554
- once(event: string, listener: (...args: any[]) => void): this;
555
- once(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
556
- once(event: "disconnect", listener: () => void): this;
557
- once(event: "error", listener: (err: Error) => void): this;
558
- once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
559
- once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
560
- once(event: "spawn", listener: () => void): this;
561
- prependListener(event: string, listener: (...args: any[]) => void): this;
562
- prependListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
563
- prependListener(event: "disconnect", listener: () => void): this;
564
- prependListener(event: "error", listener: (err: Error) => void): this;
565
- prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
566
- prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
567
- prependListener(event: "spawn", listener: () => void): this;
568
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
569
- prependOnceListener(
570
- event: "close",
571
- listener: (code: number | null, signal: NodeJS.Signals | null) => void,
572
- ): this;
573
- prependOnceListener(event: "disconnect", listener: () => void): this;
574
- prependOnceListener(event: "error", listener: (err: Error) => void): this;
575
- prependOnceListener(
576
- event: "exit",
577
- listener: (code: number | null, signal: NodeJS.Signals | null) => void,
578
- ): this;
579
- prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
580
- prependOnceListener(event: "spawn", listener: () => void): this;
581
- }
582
- // return this object when stdio option is undefined or not specified
583
- interface ChildProcessWithoutNullStreams extends ChildProcess {
584
- stdin: Writable;
585
- stdout: Readable;
586
- stderr: Readable;
587
- readonly stdio: [
588
- Writable,
589
- Readable,
590
- Readable,
591
- // stderr
592
- Readable | Writable | null | undefined,
593
- // extra, no modification
594
- Readable | Writable | null | undefined, // extra, no modification
595
- ];
596
- }
597
- // return this object when stdio option is a tuple of 3
598
- interface ChildProcessByStdio<I extends null | Writable, O extends null | Readable, E extends null | Readable>
599
- extends ChildProcess
600
- {
601
- stdin: I;
602
- stdout: O;
603
- stderr: E;
604
- readonly stdio: [
605
- I,
606
- O,
607
- E,
608
- Readable | Writable | null | undefined,
609
- // extra, no modification
610
- Readable | Writable | null | undefined, // extra, no modification
611
- ];
612
- }
613
- interface MessageOptions {
614
- keepOpen?: boolean | undefined;
615
- }
616
- type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
617
- type StdioOptions = IOType | Array<IOType | "ipc" | Stream | number | null | undefined>;
618
- type SerializationType = "json" | "advanced";
619
- interface MessagingOptions extends Abortable {
620
- /**
621
- * Specify the kind of serialization used for sending messages between processes.
622
- * @default 'json'
623
- */
624
- serialization?: SerializationType | undefined;
625
- /**
626
- * The signal value to be used when the spawned process will be killed by the abort signal.
627
- * @default 'SIGTERM'
628
- */
629
- killSignal?: NodeJS.Signals | number | undefined;
630
- /**
631
- * In milliseconds the maximum amount of time the process is allowed to run.
632
- */
633
- timeout?: number | undefined;
634
- }
635
- interface ProcessEnvOptions {
636
- uid?: number | undefined;
637
- gid?: number | undefined;
638
- cwd?: string | URL | undefined;
639
- env?: NodeJS.ProcessEnv | undefined;
640
- }
641
- interface CommonOptions extends ProcessEnvOptions {
642
- /**
643
- * @default false
644
- */
645
- windowsHide?: boolean | undefined;
646
- /**
647
- * @default 0
648
- */
649
- timeout?: number | undefined;
650
- }
651
- interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
652
- argv0?: string | undefined;
653
- /**
654
- * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
655
- * If passed as an array, the first element is used for `stdin`, the second for
656
- * `stdout`, and the third for `stderr`. A fourth element can be used to
657
- * specify the `stdio` behavior beyond the standard streams. See
658
- * {@link ChildProcess.stdio} for more information.
659
- *
660
- * @default 'pipe'
661
- */
662
- stdio?: StdioOptions | undefined;
663
- shell?: boolean | string | undefined;
664
- windowsVerbatimArguments?: boolean | undefined;
665
- }
666
- interface SpawnOptions extends CommonSpawnOptions {
667
- detached?: boolean | undefined;
668
- }
669
- interface SpawnOptionsWithoutStdio extends SpawnOptions {
670
- stdio?: StdioPipeNamed | StdioPipe[] | undefined;
671
- }
672
- type StdioNull = "inherit" | "ignore" | Stream;
673
- type StdioPipeNamed = "pipe" | "overlapped";
674
- type StdioPipe = undefined | null | StdioPipeNamed;
675
- interface SpawnOptionsWithStdioTuple<
676
- Stdin extends StdioNull | StdioPipe,
677
- Stdout extends StdioNull | StdioPipe,
678
- Stderr extends StdioNull | StdioPipe,
679
- > extends SpawnOptions {
680
- stdio: [Stdin, Stdout, Stderr];
681
- }
682
- /**
683
- * The `child_process.spawn()` method spawns a new process using the given `command`, with command-line arguments in `args`. If omitted, `args` defaults
684
- * to an empty array.
685
- *
686
- * **If the `shell` option is enabled, do not pass unsanitized user input to this**
687
- * **function. Any input containing shell metacharacters may be used to trigger**
688
- * **arbitrary command execution.**
689
- *
690
- * A third argument may be used to specify additional options, with these defaults:
691
- *
692
- * ```js
693
- * const defaults = {
694
- * cwd: undefined,
695
- * env: process.env,
696
- * };
697
- * ```
698
- *
699
- * Use `cwd` to specify the working directory from which the process is spawned.
700
- * If not given, the default is to inherit the current working directory. If given,
701
- * but the path does not exist, the child process emits an `ENOENT` error
702
- * and exits immediately. `ENOENT` is also emitted when the command
703
- * does not exist.
704
- *
705
- * Use `env` to specify environment variables that will be visible to the new
706
- * process, the default is `process.env`.
707
- *
708
- * `undefined` values in `env` will be ignored.
709
- *
710
- * Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
711
- * exit code:
712
- *
713
- * ```js
714
- * const { spawn } = require('node:child_process');
715
- * const ls = spawn('ls', ['-lh', '/usr']);
716
- *
717
- * ls.stdout.on('data', (data) => {
718
- * console.log(`stdout: ${data}`);
719
- * });
720
- *
721
- * ls.stderr.on('data', (data) => {
722
- * console.error(`stderr: ${data}`);
723
- * });
724
- *
725
- * ls.on('close', (code) => {
726
- * console.log(`child process exited with code ${code}`);
727
- * });
728
- * ```
729
- *
730
- * Example: A very elaborate way to run `ps ax | grep ssh`
731
- *
732
- * ```js
733
- * const { spawn } = require('node:child_process');
734
- * const ps = spawn('ps', ['ax']);
735
- * const grep = spawn('grep', ['ssh']);
736
- *
737
- * ps.stdout.on('data', (data) => {
738
- * grep.stdin.write(data);
739
- * });
740
- *
741
- * ps.stderr.on('data', (data) => {
742
- * console.error(`ps stderr: ${data}`);
743
- * });
744
- *
745
- * ps.on('close', (code) => {
746
- * if (code !== 0) {
747
- * console.log(`ps process exited with code ${code}`);
748
- * }
749
- * grep.stdin.end();
750
- * });
751
- *
752
- * grep.stdout.on('data', (data) => {
753
- * console.log(data.toString());
754
- * });
755
- *
756
- * grep.stderr.on('data', (data) => {
757
- * console.error(`grep stderr: ${data}`);
758
- * });
759
- *
760
- * grep.on('close', (code) => {
761
- * if (code !== 0) {
762
- * console.log(`grep process exited with code ${code}`);
763
- * }
764
- * });
765
- * ```
766
- *
767
- * Example of checking for failed `spawn`:
768
- *
769
- * ```js
770
- * const { spawn } = require('node:child_process');
771
- * const subprocess = spawn('bad_command');
772
- *
773
- * subprocess.on('error', (err) => {
774
- * console.error('Failed to start subprocess.');
775
- * });
776
- * ```
777
- *
778
- * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
779
- * title while others (Windows, SunOS) will use `command`.
780
- *
781
- * Node.js 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. Retrieve
782
- * it with the `process.argv0` property instead.
783
- *
784
- * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
785
- * the error passed to the callback will be an `AbortError`:
786
- *
787
- * ```js
788
- * const { spawn } = require('node:child_process');
789
- * const controller = new AbortController();
790
- * const { signal } = controller;
791
- * const grep = spawn('grep', ['ssh'], { signal });
792
- * grep.on('error', (err) => {
793
- * // This will be called with err being an AbortError if the controller aborts
794
- * });
795
- * controller.abort(); // Stops the child process
796
- * ```
797
- * @since v0.1.90
798
- * @param command The command to run.
799
- * @param args List of string arguments.
800
- */
801
- function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
802
- function spawn(
803
- command: string,
804
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
805
- ): ChildProcessByStdio<Writable, Readable, Readable>;
806
- function spawn(
807
- command: string,
808
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
809
- ): ChildProcessByStdio<Writable, Readable, null>;
810
- function spawn(
811
- command: string,
812
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
813
- ): ChildProcessByStdio<Writable, null, Readable>;
814
- function spawn(
815
- command: string,
816
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
817
- ): ChildProcessByStdio<null, Readable, Readable>;
818
- function spawn(
819
- command: string,
820
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
821
- ): ChildProcessByStdio<Writable, null, null>;
822
- function spawn(
823
- command: string,
824
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
825
- ): ChildProcessByStdio<null, Readable, null>;
826
- function spawn(
827
- command: string,
828
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
829
- ): ChildProcessByStdio<null, null, Readable>;
830
- function spawn(
831
- command: string,
832
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
833
- ): ChildProcessByStdio<null, null, null>;
834
- function spawn(command: string, options: SpawnOptions): ChildProcess;
835
- // overloads of spawn with 'args'
836
- function spawn(
837
- command: string,
838
- args?: readonly string[],
839
- options?: SpawnOptionsWithoutStdio,
840
- ): ChildProcessWithoutNullStreams;
841
- function spawn(
842
- command: string,
843
- args: readonly string[],
844
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
845
- ): ChildProcessByStdio<Writable, Readable, Readable>;
846
- function spawn(
847
- command: string,
848
- args: readonly string[],
849
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
850
- ): ChildProcessByStdio<Writable, Readable, null>;
851
- function spawn(
852
- command: string,
853
- args: readonly string[],
854
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
855
- ): ChildProcessByStdio<Writable, null, Readable>;
856
- function spawn(
857
- command: string,
858
- args: readonly string[],
859
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
860
- ): ChildProcessByStdio<null, Readable, Readable>;
861
- function spawn(
862
- command: string,
863
- args: readonly string[],
864
- options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
865
- ): ChildProcessByStdio<Writable, null, null>;
866
- function spawn(
867
- command: string,
868
- args: readonly string[],
869
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
870
- ): ChildProcessByStdio<null, Readable, null>;
871
- function spawn(
872
- command: string,
873
- args: readonly string[],
874
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
875
- ): ChildProcessByStdio<null, null, Readable>;
876
- function spawn(
877
- command: string,
878
- args: readonly string[],
879
- options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
880
- ): ChildProcessByStdio<null, null, null>;
881
- function spawn(command: string, args: readonly string[], options: SpawnOptions): ChildProcess;
882
- interface ExecOptions extends CommonOptions {
883
- shell?: string | undefined;
884
- signal?: AbortSignal | undefined;
885
- maxBuffer?: number | undefined;
886
- killSignal?: NodeJS.Signals | number | undefined;
887
- }
888
- interface ExecOptionsWithStringEncoding extends ExecOptions {
889
- encoding: BufferEncoding;
890
- }
891
- interface ExecOptionsWithBufferEncoding extends ExecOptions {
892
- encoding: BufferEncoding | null; // specify `null`.
893
- }
894
- interface ExecException extends Error {
895
- cmd?: string | undefined;
896
- killed?: boolean | undefined;
897
- code?: number | undefined;
898
- signal?: NodeJS.Signals | undefined;
899
- stdout?: string;
900
- stderr?: string;
901
- }
902
- /**
903
- * Spawns a shell then executes the `command` within that shell, buffering any
904
- * generated output. The `command` string passed to the exec function is processed
905
- * directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters))
906
- * need to be dealt with accordingly:
907
- *
908
- * ```js
909
- * const { exec } = require('node:child_process');
910
- *
911
- * exec('"/path/to/test file/test.sh" arg1 arg2');
912
- * // Double quotes are used so that the space in the path is not interpreted as
913
- * // a delimiter of multiple arguments.
914
- *
915
- * exec('echo "The \\$HOME variable is $HOME"');
916
- * // The $HOME variable is escaped in the first instance, but not in the second.
917
- * ```
918
- *
919
- * **Never pass unsanitized user input to this function. Any input containing shell**
920
- * **metacharacters may be used to trigger arbitrary command execution.**
921
- *
922
- * 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
923
- * `error.code` property will be
924
- * 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
925
- * process.
926
- *
927
- * The `stdout` and `stderr` arguments passed to the callback will contain the
928
- * stdout and stderr output of the child process. By default, Node.js will decode
929
- * the output as UTF-8 and pass strings to the callback. The `encoding` option
930
- * can be used to specify the character encoding used to decode the stdout and
931
- * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
932
- * encoding, `Buffer` objects will be passed to the callback instead.
933
- *
934
- * ```js
935
- * const { exec } = require('node:child_process');
936
- * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
937
- * if (error) {
938
- * console.error(`exec error: ${error}`);
939
- * return;
940
- * }
941
- * console.log(`stdout: ${stdout}`);
942
- * console.error(`stderr: ${stderr}`);
943
- * });
944
- * ```
945
- *
946
- * If `timeout` is greater than `0`, the parent will send the signal
947
- * identified by the `killSignal` property (the default is `'SIGTERM'`) if the
948
- * child runs longer than `timeout` milliseconds.
949
- *
950
- * Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace
951
- * the existing process and uses a shell to execute the command.
952
- *
953
- * If this method is invoked as its `util.promisify()` ed version, it returns
954
- * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned `ChildProcess` instance is attached to the `Promise` as a `child` property. In
955
- * case of an error (including any error resulting in an exit code other than 0), a
956
- * rejected promise is returned, with the same `error` object given in the
957
- * callback, but with two additional properties `stdout` and `stderr`.
958
- *
959
- * ```js
960
- * const util = require('node:util');
961
- * const exec = util.promisify(require('node:child_process').exec);
962
- *
963
- * async function lsExample() {
964
- * const { stdout, stderr } = await exec('ls');
965
- * console.log('stdout:', stdout);
966
- * console.error('stderr:', stderr);
967
- * }
968
- * lsExample();
969
- * ```
970
- *
971
- * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
972
- * the error passed to the callback will be an `AbortError`:
973
- *
974
- * ```js
975
- * const { exec } = require('node:child_process');
976
- * const controller = new AbortController();
977
- * const { signal } = controller;
978
- * const child = exec('grep ssh', { signal }, (error) => {
979
- * console.error(error); // an AbortError
980
- * });
981
- * controller.abort();
982
- * ```
983
- * @since v0.1.90
984
- * @param command The command to run, with space-separated arguments.
985
- * @param callback called with the output when process terminates.
986
- */
987
- function exec(
988
- command: string,
989
- callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
990
- ): ChildProcess;
991
- // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
992
- function exec(
993
- command: string,
994
- options: {
995
- encoding: "buffer" | null;
996
- } & ExecOptions,
997
- callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void,
998
- ): ChildProcess;
999
- // `options` with well known `encoding` means stdout/stderr are definitely `string`.
1000
- function exec(
1001
- command: string,
1002
- options: {
1003
- encoding: BufferEncoding;
1004
- } & ExecOptions,
1005
- callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
1006
- ): ChildProcess;
1007
- // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
1008
- // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
1009
- function exec(
1010
- command: string,
1011
- options: {
1012
- encoding: BufferEncoding;
1013
- } & ExecOptions,
1014
- callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
1015
- ): ChildProcess;
1016
- // `options` without an `encoding` means stdout/stderr are definitely `string`.
1017
- function exec(
1018
- command: string,
1019
- options: ExecOptions,
1020
- callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
1021
- ): ChildProcess;
1022
- // fallback if nothing else matches. Worst case is always `string | Buffer`.
1023
- function exec(
1024
- command: string,
1025
- options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
1026
- callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
1027
- ): ChildProcess;
1028
- interface PromiseWithChild<T> extends Promise<T> {
1029
- child: ChildProcess;
1030
- }
1031
- namespace exec {
1032
- function __promisify__(command: string): PromiseWithChild<{
1033
- stdout: string;
1034
- stderr: string;
1035
- }>;
1036
- function __promisify__(
1037
- command: string,
1038
- options: {
1039
- encoding: "buffer" | null;
1040
- } & ExecOptions,
1041
- ): PromiseWithChild<{
1042
- stdout: Buffer;
1043
- stderr: Buffer;
1044
- }>;
1045
- function __promisify__(
1046
- command: string,
1047
- options: {
1048
- encoding: BufferEncoding;
1049
- } & ExecOptions,
1050
- ): PromiseWithChild<{
1051
- stdout: string;
1052
- stderr: string;
1053
- }>;
1054
- function __promisify__(
1055
- command: string,
1056
- options: ExecOptions,
1057
- ): PromiseWithChild<{
1058
- stdout: string;
1059
- stderr: string;
1060
- }>;
1061
- function __promisify__(
1062
- command: string,
1063
- options?: (ObjectEncodingOptions & ExecOptions) | null,
1064
- ): PromiseWithChild<{
1065
- stdout: string | Buffer;
1066
- stderr: string | Buffer;
1067
- }>;
1068
- }
1069
- interface ExecFileOptions extends CommonOptions, Abortable {
1070
- maxBuffer?: number | undefined;
1071
- killSignal?: NodeJS.Signals | number | undefined;
1072
- windowsVerbatimArguments?: boolean | undefined;
1073
- shell?: boolean | string | undefined;
1074
- signal?: AbortSignal | undefined;
1075
- }
1076
- interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
1077
- encoding: BufferEncoding;
1078
- }
1079
- interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
1080
- encoding: "buffer" | null;
1081
- }
1082
- interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
1083
- encoding: BufferEncoding;
1084
- }
1085
- type ExecFileException =
1086
- & Omit<ExecException, "code">
1087
- & Omit<NodeJS.ErrnoException, "code">
1088
- & { code?: string | number | undefined | null };
1089
- /**
1090
- * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
1091
- * executable `file` is spawned directly as a new process making it slightly more
1092
- * efficient than {@link exec}.
1093
- *
1094
- * The same options as {@link exec} are supported. Since a shell is
1095
- * not spawned, behaviors such as I/O redirection and file globbing are not
1096
- * supported.
1097
- *
1098
- * ```js
1099
- * const { execFile } = require('node:child_process');
1100
- * const child = execFile('node', ['--version'], (error, stdout, stderr) => {
1101
- * if (error) {
1102
- * throw error;
1103
- * }
1104
- * console.log(stdout);
1105
- * });
1106
- * ```
1107
- *
1108
- * The `stdout` and `stderr` arguments passed to the callback will contain the
1109
- * stdout and stderr output of the child process. By default, Node.js will decode
1110
- * the output as UTF-8 and pass strings to the callback. The `encoding` option
1111
- * can be used to specify the character encoding used to decode the stdout and
1112
- * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
1113
- * encoding, `Buffer` objects will be passed to the callback instead.
1114
- *
1115
- * If this method is invoked as its `util.promisify()` ed version, it returns
1116
- * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned `ChildProcess` instance is attached to the `Promise` as a `child` property. In
1117
- * case of an error (including any error resulting in an exit code other than 0), a
1118
- * rejected promise is returned, with the same `error` object given in the
1119
- * callback, but with two additional properties `stdout` and `stderr`.
1120
- *
1121
- * ```js
1122
- * const util = require('node:util');
1123
- * const execFile = util.promisify(require('node:child_process').execFile);
1124
- * async function getVersion() {
1125
- * const { stdout } = await execFile('node', ['--version']);
1126
- * console.log(stdout);
1127
- * }
1128
- * getVersion();
1129
- * ```
1130
- *
1131
- * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1132
- * **function. Any input containing shell metacharacters may be used to trigger**
1133
- * **arbitrary command execution.**
1134
- *
1135
- * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
1136
- * the error passed to the callback will be an `AbortError`:
1137
- *
1138
- * ```js
1139
- * const { execFile } = require('node:child_process');
1140
- * const controller = new AbortController();
1141
- * const { signal } = controller;
1142
- * const child = execFile('node', ['--version'], { signal }, (error) => {
1143
- * console.error(error); // an AbortError
1144
- * });
1145
- * controller.abort();
1146
- * ```
1147
- * @since v0.1.91
1148
- * @param file The name or path of the executable file to run.
1149
- * @param args List of string arguments.
1150
- * @param callback Called with the output when process terminates.
1151
- */
1152
- function execFile(file: string): ChildProcess;
1153
- function execFile(
1154
- file: string,
1155
- options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1156
- ): ChildProcess;
1157
- function execFile(file: string, args?: readonly string[] | null): ChildProcess;
1158
- function execFile(
1159
- file: string,
1160
- args: readonly string[] | undefined | null,
1161
- options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1162
- ): ChildProcess;
1163
- // no `options` definitely means stdout/stderr are `string`.
1164
- function execFile(
1165
- file: string,
1166
- callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
1167
- ): ChildProcess;
1168
- function execFile(
1169
- file: string,
1170
- args: readonly string[] | undefined | null,
1171
- callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
1172
- ): ChildProcess;
1173
- // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
1174
- function execFile(
1175
- file: string,
1176
- options: ExecFileOptionsWithBufferEncoding,
1177
- callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
1178
- ): ChildProcess;
1179
- function execFile(
1180
- file: string,
1181
- args: readonly string[] | undefined | null,
1182
- options: ExecFileOptionsWithBufferEncoding,
1183
- callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
1184
- ): ChildProcess;
1185
- // `options` with well known `encoding` means stdout/stderr are definitely `string`.
1186
- function execFile(
1187
- file: string,
1188
- options: ExecFileOptionsWithStringEncoding,
1189
- callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
1190
- ): ChildProcess;
1191
- function execFile(
1192
- file: string,
1193
- args: readonly string[] | undefined | null,
1194
- options: ExecFileOptionsWithStringEncoding,
1195
- callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
1196
- ): ChildProcess;
1197
- // `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
1198
- // There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
1199
- function execFile(
1200
- file: string,
1201
- options: ExecFileOptionsWithOtherEncoding,
1202
- callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
1203
- ): ChildProcess;
1204
- function execFile(
1205
- file: string,
1206
- args: readonly string[] | undefined | null,
1207
- options: ExecFileOptionsWithOtherEncoding,
1208
- callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
1209
- ): ChildProcess;
1210
- // `options` without an `encoding` means stdout/stderr are definitely `string`.
1211
- function execFile(
1212
- file: string,
1213
- options: ExecFileOptions,
1214
- callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
1215
- ): ChildProcess;
1216
- function execFile(
1217
- file: string,
1218
- args: readonly string[] | undefined | null,
1219
- options: ExecFileOptions,
1220
- callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
1221
- ): ChildProcess;
1222
- // fallback if nothing else matches. Worst case is always `string | Buffer`.
1223
- function execFile(
1224
- file: string,
1225
- options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1226
- callback:
1227
- | ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void)
1228
- | undefined
1229
- | null,
1230
- ): ChildProcess;
1231
- function execFile(
1232
- file: string,
1233
- args: readonly string[] | undefined | null,
1234
- options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1235
- callback:
1236
- | ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void)
1237
- | undefined
1238
- | null,
1239
- ): ChildProcess;
1240
- namespace execFile {
1241
- function __promisify__(file: string): PromiseWithChild<{
1242
- stdout: string;
1243
- stderr: string;
1244
- }>;
1245
- function __promisify__(
1246
- file: string,
1247
- args: readonly string[] | undefined | null,
1248
- ): PromiseWithChild<{
1249
- stdout: string;
1250
- stderr: string;
1251
- }>;
1252
- function __promisify__(
1253
- file: string,
1254
- options: ExecFileOptionsWithBufferEncoding,
1255
- ): PromiseWithChild<{
1256
- stdout: Buffer;
1257
- stderr: Buffer;
1258
- }>;
1259
- function __promisify__(
1260
- file: string,
1261
- args: readonly string[] | undefined | null,
1262
- options: ExecFileOptionsWithBufferEncoding,
1263
- ): PromiseWithChild<{
1264
- stdout: Buffer;
1265
- stderr: Buffer;
1266
- }>;
1267
- function __promisify__(
1268
- file: string,
1269
- options: ExecFileOptionsWithStringEncoding,
1270
- ): PromiseWithChild<{
1271
- stdout: string;
1272
- stderr: string;
1273
- }>;
1274
- function __promisify__(
1275
- file: string,
1276
- args: readonly string[] | undefined | null,
1277
- options: ExecFileOptionsWithStringEncoding,
1278
- ): PromiseWithChild<{
1279
- stdout: string;
1280
- stderr: string;
1281
- }>;
1282
- function __promisify__(
1283
- file: string,
1284
- options: ExecFileOptionsWithOtherEncoding,
1285
- ): PromiseWithChild<{
1286
- stdout: string | Buffer;
1287
- stderr: string | Buffer;
1288
- }>;
1289
- function __promisify__(
1290
- file: string,
1291
- args: readonly string[] | undefined | null,
1292
- options: ExecFileOptionsWithOtherEncoding,
1293
- ): PromiseWithChild<{
1294
- stdout: string | Buffer;
1295
- stderr: string | Buffer;
1296
- }>;
1297
- function __promisify__(
1298
- file: string,
1299
- options: ExecFileOptions,
1300
- ): PromiseWithChild<{
1301
- stdout: string;
1302
- stderr: string;
1303
- }>;
1304
- function __promisify__(
1305
- file: string,
1306
- args: readonly string[] | undefined | null,
1307
- options: ExecFileOptions,
1308
- ): PromiseWithChild<{
1309
- stdout: string;
1310
- stderr: string;
1311
- }>;
1312
- function __promisify__(
1313
- file: string,
1314
- options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1315
- ): PromiseWithChild<{
1316
- stdout: string | Buffer;
1317
- stderr: string | Buffer;
1318
- }>;
1319
- function __promisify__(
1320
- file: string,
1321
- args: readonly string[] | undefined | null,
1322
- options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
1323
- ): PromiseWithChild<{
1324
- stdout: string | Buffer;
1325
- stderr: string | Buffer;
1326
- }>;
1327
- }
1328
- interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
1329
- execPath?: string | undefined;
1330
- execArgv?: string[] | undefined;
1331
- silent?: boolean | undefined;
1332
- /**
1333
- * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
1334
- * If passed as an array, the first element is used for `stdin`, the second for
1335
- * `stdout`, and the third for `stderr`. A fourth element can be used to
1336
- * specify the `stdio` behavior beyond the standard streams. See
1337
- * {@link ChildProcess.stdio} for more information.
1338
- *
1339
- * @default 'pipe'
1340
- */
1341
- stdio?: StdioOptions | undefined;
1342
- detached?: boolean | undefined;
1343
- windowsVerbatimArguments?: boolean | undefined;
1344
- }
1345
- /**
1346
- * The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes.
1347
- * Like {@link spawn}, a `ChildProcess` object is returned. The
1348
- * returned `ChildProcess` will have an additional communication channel
1349
- * built-in that allows messages to be passed back and forth between the parent and
1350
- * child. See `subprocess.send()` for details.
1351
- *
1352
- * Keep in mind that spawned Node.js child processes are
1353
- * independent of the parent with exception of the IPC communication channel
1354
- * that is established between the two. Each process has its own memory, with
1355
- * their own V8 instances. Because of the additional resource allocations
1356
- * required, spawning a large number of child Node.js processes is not
1357
- * recommended.
1358
- *
1359
- * 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
1360
- * execution path to be used.
1361
- *
1362
- * Node.js processes launched with a custom `execPath` will communicate with the
1363
- * parent process using the file descriptor (fd) identified using the
1364
- * environment variable `NODE_CHANNEL_FD` on the child process.
1365
- *
1366
- * Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
1367
- * current process.
1368
- *
1369
- * The `shell` option available in {@link spawn} is not supported by `child_process.fork()` and will be ignored if set.
1370
- *
1371
- * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
1372
- * the error passed to the callback will be an `AbortError`:
1373
- *
1374
- * ```js
1375
- * if (process.argv[2] === 'child') {
1376
- * setTimeout(() => {
1377
- * console.log(`Hello from ${process.argv[2]}!`);
1378
- * }, 1_000);
1379
- * } else {
1380
- * const { fork } = require('node:child_process');
1381
- * const controller = new AbortController();
1382
- * const { signal } = controller;
1383
- * const child = fork(__filename, ['child'], { signal });
1384
- * child.on('error', (err) => {
1385
- * // This will be called with err being an AbortError if the controller aborts
1386
- * });
1387
- * controller.abort(); // Stops the child process
1388
- * }
1389
- * ```
1390
- * @since v0.5.0
1391
- * @param modulePath The module to run in the child.
1392
- * @param args List of string arguments.
1393
- */
1394
- function fork(modulePath: string, options?: ForkOptions): ChildProcess;
1395
- function fork(modulePath: string, args?: readonly string[], options?: ForkOptions): ChildProcess;
1396
- interface SpawnSyncOptions extends CommonSpawnOptions {
1397
- input?: string | NodeJS.ArrayBufferView | undefined;
1398
- maxBuffer?: number | undefined;
1399
- encoding?: BufferEncoding | "buffer" | null | undefined;
1400
- }
1401
- interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
1402
- encoding: BufferEncoding;
1403
- }
1404
- interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
1405
- encoding?: "buffer" | null | undefined;
1406
- }
1407
- interface SpawnSyncReturns<T> {
1408
- pid: number;
1409
- output: Array<T | null>;
1410
- stdout: T;
1411
- stderr: T;
1412
- status: number | null;
1413
- signal: NodeJS.Signals | null;
1414
- error?: Error | undefined;
1415
- }
1416
- /**
1417
- * The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
1418
- * until the child process has fully closed. When a timeout has been encountered
1419
- * and `killSignal` is sent, the method won't return until the process has
1420
- * completely exited. If the process intercepts and handles the `SIGTERM` signal
1421
- * and doesn't exit, the parent process will wait until the child process has
1422
- * exited.
1423
- *
1424
- * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1425
- * **function. Any input containing shell metacharacters may be used to trigger**
1426
- * **arbitrary command execution.**
1427
- * @since v0.11.12
1428
- * @param command The command to run.
1429
- * @param args List of string arguments.
1430
- */
1431
- function spawnSync(command: string): SpawnSyncReturns<Buffer>;
1432
- function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
1433
- function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
1434
- function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
1435
- function spawnSync(command: string, args: readonly string[]): SpawnSyncReturns<Buffer>;
1436
- function spawnSync(
1437
- command: string,
1438
- args: readonly string[],
1439
- options: SpawnSyncOptionsWithStringEncoding,
1440
- ): SpawnSyncReturns<string>;
1441
- function spawnSync(
1442
- command: string,
1443
- args: readonly string[],
1444
- options: SpawnSyncOptionsWithBufferEncoding,
1445
- ): SpawnSyncReturns<Buffer>;
1446
- function spawnSync(
1447
- command: string,
1448
- args?: readonly string[],
1449
- options?: SpawnSyncOptions,
1450
- ): SpawnSyncReturns<string | Buffer>;
1451
- interface CommonExecOptions extends CommonOptions {
1452
- input?: string | NodeJS.ArrayBufferView | undefined;
1453
- /**
1454
- * Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings.
1455
- * If passed as an array, the first element is used for `stdin`, the second for
1456
- * `stdout`, and the third for `stderr`. A fourth element can be used to
1457
- * specify the `stdio` behavior beyond the standard streams. See
1458
- * {@link ChildProcess.stdio} for more information.
1459
- *
1460
- * @default 'pipe'
1461
- */
1462
- stdio?: StdioOptions | undefined;
1463
- killSignal?: NodeJS.Signals | number | undefined;
1464
- maxBuffer?: number | undefined;
1465
- encoding?: BufferEncoding | "buffer" | null | undefined;
1466
- }
1467
- interface ExecSyncOptions extends CommonExecOptions {
1468
- shell?: string | undefined;
1469
- }
1470
- interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
1471
- encoding: BufferEncoding;
1472
- }
1473
- interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
1474
- encoding?: "buffer" | null | undefined;
1475
- }
1476
- /**
1477
- * The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return
1478
- * until the child process has fully closed. When a timeout has been encountered
1479
- * and `killSignal` is sent, the method won't return until the process has
1480
- * 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
1481
- * has exited.
1482
- *
1483
- * If the process times out or has a non-zero exit code, this method will throw.
1484
- * The `Error` object will contain the entire result from {@link spawnSync}.
1485
- *
1486
- * **Never pass unsanitized user input to this function. Any input containing shell**
1487
- * **metacharacters may be used to trigger arbitrary command execution.**
1488
- * @since v0.11.12
1489
- * @param command The command to run.
1490
- * @return The stdout from the command.
1491
- */
1492
- function execSync(command: string): Buffer;
1493
- function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string;
1494
- function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer;
1495
- function execSync(command: string, options?: ExecSyncOptions): string | Buffer;
1496
- interface ExecFileSyncOptions extends CommonExecOptions {
1497
- shell?: boolean | string | undefined;
1498
- }
1499
- interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
1500
- encoding: BufferEncoding;
1501
- }
1502
- interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
1503
- encoding?: "buffer" | null; // specify `null`.
1504
- }
1505
- /**
1506
- * The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not
1507
- * return until the child process has fully closed. When a timeout has been
1508
- * encountered and `killSignal` is sent, the method won't return until the process
1509
- * has completely exited.
1510
- *
1511
- * If the child process intercepts and handles the `SIGTERM` signal and
1512
- * does not exit, the parent process will still wait until the child process has
1513
- * exited.
1514
- *
1515
- * 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}.
1516
- *
1517
- * **If the `shell` option is enabled, do not pass unsanitized user input to this**
1518
- * **function. Any input containing shell metacharacters may be used to trigger**
1519
- * **arbitrary command execution.**
1520
- * @since v0.11.12
1521
- * @param file The name or path of the executable file to run.
1522
- * @param args List of string arguments.
1523
- * @return The stdout from the command.
1524
- */
1525
- function execFileSync(file: string): Buffer;
1526
- function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string;
1527
- function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1528
- function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer;
1529
- function execFileSync(file: string, args: readonly string[]): Buffer;
1530
- function execFileSync(
1531
- file: string,
1532
- args: readonly string[],
1533
- options: ExecFileSyncOptionsWithStringEncoding,
1534
- ): string;
1535
- function execFileSync(
1536
- file: string,
1537
- args: readonly string[],
1538
- options: ExecFileSyncOptionsWithBufferEncoding,
1539
- ): Buffer;
1540
- function execFileSync(file: string, args?: readonly string[], options?: ExecFileSyncOptions): string | Buffer;
1541
- }
1542
- declare module "node:child_process" {
1543
- export * from "child_process";
1544
- }