rahad-media-downloader 2.1.12 → 2.1.14

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