aizryu.js 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/env.json +1 -0
- package/.cache/typescript/5.0/node_modules/.package-lock.json +156 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/index.d.ts +95 -0
- package/.cache/typescript/5.0/node_modules/@types/body-parser/package.json +58 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/index.d.ts +91 -0
- package/.cache/typescript/5.0/node_modules/@types/connect/package.json +32 -0
- package/.cache/typescript/5.0/node_modules/@types/express/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/express/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/express/index.d.ts +128 -0
- package/.cache/typescript/5.0/node_modules/@types/express/package.json +45 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/index.d.ts +1261 -0
- package/.cache/typescript/5.0/node_modules/@types/express-serve-static-core/package.json +55 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/index.d.ts +77 -0
- package/.cache/typescript/5.0/node_modules/@types/http-errors/package.json +30 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/base.d.ts +456 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/index.d.ts +18 -0
- package/.cache/typescript/5.0/node_modules/@types/jsdom/package.json +45 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/Mime.d.ts +10 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/index.d.ts +31 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/lite.d.ts +7 -0
- package/.cache/typescript/5.0/node_modules/@types/mime/package.json +30 -0
- package/.cache/typescript/5.0/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/@types/node/assert.d.ts +996 -0
- package/.cache/typescript/5.0/node_modules/@types/node/async_hooks.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/buffer.d.ts +2362 -0
- package/.cache/typescript/5.0/node_modules/@types/node/child_process.d.ts +1540 -0
- package/.cache/typescript/5.0/node_modules/@types/node/cluster.d.ts +432 -0
- package/.cache/typescript/5.0/node_modules/@types/node/console.d.ts +415 -0
- package/.cache/typescript/5.0/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/@types/node/crypto.d.ts +4456 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dgram.d.ts +586 -0
- package/.cache/typescript/5.0/node_modules/@types/node/diagnostics_channel.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dns/promises.d.ts +425 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dns.d.ts +809 -0
- package/.cache/typescript/5.0/node_modules/@types/node/dom-events.d.ts +122 -0
- package/.cache/typescript/5.0/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.0/node_modules/@types/node/events.d.ts +879 -0
- package/.cache/typescript/5.0/node_modules/@types/node/fs/promises.d.ts +1239 -0
- package/.cache/typescript/5.0/node_modules/@types/node/fs.d.ts +4291 -0
- package/.cache/typescript/5.0/node_modules/@types/node/globals.d.ts +381 -0
- package/.cache/typescript/5.0/node_modules/@types/node/globals.global.d.ts +1 -0
- package/.cache/typescript/5.0/node_modules/@types/node/http.d.ts +1888 -0
- package/.cache/typescript/5.0/node_modules/@types/node/http2.d.ts +2382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/https.d.ts +550 -0
- package/.cache/typescript/5.0/node_modules/@types/node/index.d.ts +88 -0
- package/.cache/typescript/5.0/node_modules/@types/node/inspector.d.ts +2747 -0
- package/.cache/typescript/5.0/node_modules/@types/node/module.d.ts +301 -0
- package/.cache/typescript/5.0/node_modules/@types/node/net.d.ts +949 -0
- package/.cache/typescript/5.0/node_modules/@types/node/os.d.ts +478 -0
- package/.cache/typescript/5.0/node_modules/@types/node/package.json +230 -0
- package/.cache/typescript/5.0/node_modules/@types/node/path.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/perf_hooks.d.ts +639 -0
- package/.cache/typescript/5.0/node_modules/@types/node/process.d.ts +1532 -0
- package/.cache/typescript/5.0/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.0/node_modules/@types/node/querystring.d.ts +141 -0
- package/.cache/typescript/5.0/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.0/node_modules/@types/node/readline.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream/web.d.ts +350 -0
- package/.cache/typescript/5.0/node_modules/@types/node/stream.d.ts +1701 -0
- package/.cache/typescript/5.0/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.0/node_modules/@types/node/test.d.ts +1382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/timers/promises.d.ts +93 -0
- package/.cache/typescript/5.0/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.0/node_modules/@types/node/tls.d.ts +1210 -0
- package/.cache/typescript/5.0/node_modules/@types/node/trace_events.d.ts +182 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/assert.d.ts +996 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/async_hooks.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/buffer.d.ts +2362 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/child_process.d.ts +1540 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/cluster.d.ts +432 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/console.d.ts +415 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/constants.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/crypto.d.ts +4455 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dgram.d.ts +586 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dns/promises.d.ts +425 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dns.d.ts +809 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/dom-events.d.ts +122 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/events.d.ts +879 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/fs/promises.d.ts +1239 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/fs.d.ts +4291 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/globals.d.ts +381 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/http.d.ts +1888 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/http2.d.ts +2382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/https.d.ts +550 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/index.d.ts +88 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/inspector.d.ts +2747 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/module.d.ts +301 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/net.d.ts +949 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/os.d.ts +478 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/perf_hooks.d.ts +639 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/process.d.ts +1532 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/querystring.d.ts +141 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/readline.d.ts +539 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/repl.d.ts +430 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream/web.d.ts +350 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/stream.d.ts +1701 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/test.d.ts +1382 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/timers.d.ts +240 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/tls.d.ts +1210 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/trace_events.d.ts +182 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/tty.d.ts +208 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/url.d.ts +927 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/util.d.ts +2186 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/v8.d.ts +635 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/vm.d.ts +903 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/worker_threads.d.ts +691 -0
- package/.cache/typescript/5.0/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/.cache/typescript/5.0/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.0/node_modules/@types/node/url.d.ts +927 -0
- package/.cache/typescript/5.0/node_modules/@types/node/util.d.ts +2186 -0
- package/.cache/typescript/5.0/node_modules/@types/node/v8.d.ts +635 -0
- package/.cache/typescript/5.0/node_modules/@types/node/vm.d.ts +903 -0
- package/.cache/typescript/5.0/node_modules/@types/node/wasi.d.ts +158 -0
- package/.cache/typescript/5.0/node_modules/@types/node/worker_threads.d.ts +691 -0
- package/.cache/typescript/5.0/node_modules/@types/node/zlib.d.ts +517 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/README.md +75 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/index.d.ts +56 -0
- package/.cache/typescript/5.0/node_modules/@types/qs/package.json +65 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/README.md +53 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/index.d.ts +34 -0
- package/.cache/typescript/5.0/node_modules/@types/range-parser/package.json +25 -0
- package/.cache/typescript/5.0/node_modules/@types/send/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/send/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/send/index.d.ts +225 -0
- package/.cache/typescript/5.0/node_modules/@types/send/package.json +33 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/index.d.ts +107 -0
- package/.cache/typescript/5.0/node_modules/@types/serve-static/package.json +39 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/LICENSE +21 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/README.md +15 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/index.d.ts +321 -0
- package/.cache/typescript/5.0/node_modules/@types/tough-cookie/package.json +35 -0
- package/.cache/typescript/5.0/node_modules/entities/LICENSE +11 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.d.ts +211 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.js +536 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.js +76 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/decode_codepoint.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.d.ts +22 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.js +77 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/encode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.d.ts +43 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.js +122 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/escape.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.d.ts +211 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.js +496 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.js +71 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/decode_codepoint.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.d.ts +22 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.js +69 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/encode.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.d.ts +43 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.js +116 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/escape.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.js +7 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.js +7 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.js +10 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/generated/encode-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.d.ts +96 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.js +99 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/index.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/esm/package.json +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.js +9 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.js +9 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/decode-data-xml.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.js +12 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/generated/encode-html.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.d.ts +96 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.d.ts.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.js +126 -0
- package/.cache/typescript/5.0/node_modules/entities/lib/index.js.map +1 -0
- package/.cache/typescript/5.0/node_modules/entities/package.json +90 -0
- package/.cache/typescript/5.0/node_modules/entities/readme.md +122 -0
- package/.cache/typescript/5.0/node_modules/parse5/LICENSE +19 -0
- package/.cache/typescript/5.0/node_modules/parse5/README.md +38 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/doctype.d.ts +5 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/doctype.js +120 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/error-codes.d.ts +68 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/error-codes.js +67 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/foreign-content.d.ts +10 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/foreign-content.js +239 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/html.d.ts +288 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/html.js +529 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/token.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/token.js +25 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/unicode.d.ts +49 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/common/unicode.js +77 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/index.d.ts +60 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/index.js +57 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/package.json +1 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/formatting-element-list.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/formatting-element-list.js +115 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/index.d.ts +157 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/index.js +3163 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/open-element-stack.d.ts +53 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/parser/open-element-stack.js +316 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/serializer/index.d.ts +61 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/serializer/index.js +173 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/index.d.ts +248 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/index.js +2908 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/preprocessor.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tokenizer/preprocessor.js +199 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/default.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/default.js +177 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/interface.d.ts +250 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/cjs/tree-adapters/interface.js +3 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/doctype.d.ts +5 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/doctype.js +115 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/error-codes.d.ts +68 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/error-codes.js +64 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/foreign-content.d.ts +10 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/foreign-content.js +230 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/html.d.ts +288 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/html.js +523 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/token.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/token.js +21 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/unicode.d.ts +49 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/common/unicode.js +69 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/index.d.ts +60 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/index.js +45 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/formatting-element-list.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/formatting-element-list.js +111 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/index.d.ts +157 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/index.js +3168 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/open-element-stack.d.ts +53 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/parser/open-element-stack.js +312 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/serializer/index.d.ts +61 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/serializer/index.js +168 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/index.d.ts +248 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/index.js +2904 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/preprocessor.d.ts +37 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tokenizer/preprocessor.js +195 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/default.d.ts +85 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/default.js +174 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/interface.d.ts +250 -0
- package/.cache/typescript/5.0/node_modules/parse5/dist/tree-adapters/interface.js +2 -0
- package/.cache/typescript/5.0/node_modules/parse5/package.json +50 -0
- package/.cache/typescript/5.0/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.0/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.0/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.0/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.0/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.0/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.0/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/.cache/typescript/5.0/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.0/node_modules/undici-types/client.d.ts +97 -0
- package/.cache/typescript/5.0/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.0/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.0/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.0/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/.cache/typescript/5.0/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/.cache/typescript/5.0/node_modules/undici-types/errors.d.ts +128 -0
- package/.cache/typescript/5.0/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.0/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.0/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.0/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.0/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.0/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.0/node_modules/undici-types/handlers.d.ts +9 -0
- package/.cache/typescript/5.0/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.0/node_modules/undici-types/index.d.ts +63 -0
- package/.cache/typescript/5.0/node_modules/undici-types/interceptors.d.ts +5 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.0/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.0/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.0/node_modules/undici-types/patch.d.ts +71 -0
- package/.cache/typescript/5.0/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.0/node_modules/undici-types/pool.d.ts +28 -0
- package/.cache/typescript/5.0/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/.cache/typescript/5.0/node_modules/undici-types/readable.d.ts +61 -0
- package/.cache/typescript/5.0/node_modules/undici-types/webidl.d.ts +220 -0
- package/.cache/typescript/5.0/node_modules/undici-types/websocket.d.ts +131 -0
- package/.cache/typescript/5.0/package-lock.json +166 -0
- package/.cache/typescript/5.0/package.json +1 -0
- package/.replit +14 -0
- package/.upm/store.json +1 -0
- package/README.md +24 -0
- package/index.js +1 -0
- package/package.json +21 -0
@@ -0,0 +1,1540 @@
|
|
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.2.0/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
|
+
}
|
898
|
+
/**
|
899
|
+
* Spawns a shell then executes the `command` within that shell, buffering any
|
900
|
+
* generated output. The `command` string passed to the exec function is processed
|
901
|
+
* directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters))
|
902
|
+
* need to be dealt with accordingly:
|
903
|
+
*
|
904
|
+
* ```js
|
905
|
+
* const { exec } = require('node:child_process');
|
906
|
+
*
|
907
|
+
* exec('"/path/to/test file/test.sh" arg1 arg2');
|
908
|
+
* // Double quotes are used so that the space in the path is not interpreted as
|
909
|
+
* // a delimiter of multiple arguments.
|
910
|
+
*
|
911
|
+
* exec('echo "The \\$HOME variable is $HOME"');
|
912
|
+
* // The $HOME variable is escaped in the first instance, but not in the second.
|
913
|
+
* ```
|
914
|
+
*
|
915
|
+
* **Never pass unsanitized user input to this function. Any input containing shell**
|
916
|
+
* **metacharacters may be used to trigger arbitrary command execution.**
|
917
|
+
*
|
918
|
+
* 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
|
919
|
+
* `error.code` property will be
|
920
|
+
* 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
|
921
|
+
* process.
|
922
|
+
*
|
923
|
+
* The `stdout` and `stderr` arguments passed to the callback will contain the
|
924
|
+
* stdout and stderr output of the child process. By default, Node.js will decode
|
925
|
+
* the output as UTF-8 and pass strings to the callback. The `encoding` option
|
926
|
+
* can be used to specify the character encoding used to decode the stdout and
|
927
|
+
* stderr output. If `encoding` is `'buffer'`, or an unrecognized character
|
928
|
+
* encoding, `Buffer` objects will be passed to the callback instead.
|
929
|
+
*
|
930
|
+
* ```js
|
931
|
+
* const { exec } = require('node:child_process');
|
932
|
+
* exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
|
933
|
+
* if (error) {
|
934
|
+
* console.error(`exec error: ${error}`);
|
935
|
+
* return;
|
936
|
+
* }
|
937
|
+
* console.log(`stdout: ${stdout}`);
|
938
|
+
* console.error(`stderr: ${stderr}`);
|
939
|
+
* });
|
940
|
+
* ```
|
941
|
+
*
|
942
|
+
* If `timeout` is greater than `0`, the parent will send the signal
|
943
|
+
* identified by the `killSignal` property (the default is `'SIGTERM'`) if the
|
944
|
+
* child runs longer than `timeout` milliseconds.
|
945
|
+
*
|
946
|
+
* Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace
|
947
|
+
* the existing process and uses a shell to execute the command.
|
948
|
+
*
|
949
|
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
950
|
+
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
951
|
+
* case of an error (including any error resulting in an exit code other than 0), a
|
952
|
+
* rejected promise is returned, with the same `error` object given in the
|
953
|
+
* callback, but with two additional properties `stdout` and `stderr`.
|
954
|
+
*
|
955
|
+
* ```js
|
956
|
+
* const util = require('node:util');
|
957
|
+
* const exec = util.promisify(require('node:child_process').exec);
|
958
|
+
*
|
959
|
+
* async function lsExample() {
|
960
|
+
* const { stdout, stderr } = await exec('ls');
|
961
|
+
* console.log('stdout:', stdout);
|
962
|
+
* console.error('stderr:', stderr);
|
963
|
+
* }
|
964
|
+
* lsExample();
|
965
|
+
* ```
|
966
|
+
*
|
967
|
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
968
|
+
* the error passed to the callback will be an `AbortError`:
|
969
|
+
*
|
970
|
+
* ```js
|
971
|
+
* const { exec } = require('node:child_process');
|
972
|
+
* const controller = new AbortController();
|
973
|
+
* const { signal } = controller;
|
974
|
+
* const child = exec('grep ssh', { signal }, (error) => {
|
975
|
+
* console.error(error); // an AbortError
|
976
|
+
* });
|
977
|
+
* controller.abort();
|
978
|
+
* ```
|
979
|
+
* @since v0.1.90
|
980
|
+
* @param command The command to run, with space-separated arguments.
|
981
|
+
* @param callback called with the output when process terminates.
|
982
|
+
*/
|
983
|
+
function exec(
|
984
|
+
command: string,
|
985
|
+
callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
|
986
|
+
): ChildProcess;
|
987
|
+
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
|
988
|
+
function exec(
|
989
|
+
command: string,
|
990
|
+
options: {
|
991
|
+
encoding: "buffer" | null;
|
992
|
+
} & ExecOptions,
|
993
|
+
callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void,
|
994
|
+
): ChildProcess;
|
995
|
+
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
|
996
|
+
function exec(
|
997
|
+
command: string,
|
998
|
+
options: {
|
999
|
+
encoding: BufferEncoding;
|
1000
|
+
} & ExecOptions,
|
1001
|
+
callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
|
1002
|
+
): ChildProcess;
|
1003
|
+
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
|
1004
|
+
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
|
1005
|
+
function exec(
|
1006
|
+
command: string,
|
1007
|
+
options: {
|
1008
|
+
encoding: BufferEncoding;
|
1009
|
+
} & ExecOptions,
|
1010
|
+
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1011
|
+
): ChildProcess;
|
1012
|
+
// `options` without an `encoding` means stdout/stderr are definitely `string`.
|
1013
|
+
function exec(
|
1014
|
+
command: string,
|
1015
|
+
options: ExecOptions,
|
1016
|
+
callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
|
1017
|
+
): ChildProcess;
|
1018
|
+
// fallback if nothing else matches. Worst case is always `string | Buffer`.
|
1019
|
+
function exec(
|
1020
|
+
command: string,
|
1021
|
+
options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
|
1022
|
+
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1023
|
+
): ChildProcess;
|
1024
|
+
interface PromiseWithChild<T> extends Promise<T> {
|
1025
|
+
child: ChildProcess;
|
1026
|
+
}
|
1027
|
+
namespace exec {
|
1028
|
+
function __promisify__(command: string): PromiseWithChild<{
|
1029
|
+
stdout: string;
|
1030
|
+
stderr: string;
|
1031
|
+
}>;
|
1032
|
+
function __promisify__(
|
1033
|
+
command: string,
|
1034
|
+
options: {
|
1035
|
+
encoding: "buffer" | null;
|
1036
|
+
} & ExecOptions,
|
1037
|
+
): PromiseWithChild<{
|
1038
|
+
stdout: Buffer;
|
1039
|
+
stderr: Buffer;
|
1040
|
+
}>;
|
1041
|
+
function __promisify__(
|
1042
|
+
command: string,
|
1043
|
+
options: {
|
1044
|
+
encoding: BufferEncoding;
|
1045
|
+
} & ExecOptions,
|
1046
|
+
): PromiseWithChild<{
|
1047
|
+
stdout: string;
|
1048
|
+
stderr: string;
|
1049
|
+
}>;
|
1050
|
+
function __promisify__(
|
1051
|
+
command: string,
|
1052
|
+
options: ExecOptions,
|
1053
|
+
): PromiseWithChild<{
|
1054
|
+
stdout: string;
|
1055
|
+
stderr: string;
|
1056
|
+
}>;
|
1057
|
+
function __promisify__(
|
1058
|
+
command: string,
|
1059
|
+
options?: (ObjectEncodingOptions & ExecOptions) | null,
|
1060
|
+
): PromiseWithChild<{
|
1061
|
+
stdout: string | Buffer;
|
1062
|
+
stderr: string | Buffer;
|
1063
|
+
}>;
|
1064
|
+
}
|
1065
|
+
interface ExecFileOptions extends CommonOptions, Abortable {
|
1066
|
+
maxBuffer?: number | undefined;
|
1067
|
+
killSignal?: NodeJS.Signals | number | undefined;
|
1068
|
+
windowsVerbatimArguments?: boolean | undefined;
|
1069
|
+
shell?: boolean | string | undefined;
|
1070
|
+
signal?: AbortSignal | undefined;
|
1071
|
+
}
|
1072
|
+
interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
|
1073
|
+
encoding: BufferEncoding;
|
1074
|
+
}
|
1075
|
+
interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
|
1076
|
+
encoding: "buffer" | null;
|
1077
|
+
}
|
1078
|
+
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
|
1079
|
+
encoding: BufferEncoding;
|
1080
|
+
}
|
1081
|
+
type ExecFileException =
|
1082
|
+
& Omit<ExecException, "code">
|
1083
|
+
& Omit<NodeJS.ErrnoException, "code">
|
1084
|
+
& { code?: string | number | undefined | null };
|
1085
|
+
/**
|
1086
|
+
* The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
|
1087
|
+
* executable `file` is spawned directly as a new process making it slightly more
|
1088
|
+
* efficient than {@link exec}.
|
1089
|
+
*
|
1090
|
+
* The same options as {@link exec} are supported. Since a shell is
|
1091
|
+
* not spawned, behaviors such as I/O redirection and file globbing are not
|
1092
|
+
* supported.
|
1093
|
+
*
|
1094
|
+
* ```js
|
1095
|
+
* const { execFile } = require('node:child_process');
|
1096
|
+
* const child = execFile('node', ['--version'], (error, stdout, stderr) => {
|
1097
|
+
* if (error) {
|
1098
|
+
* throw error;
|
1099
|
+
* }
|
1100
|
+
* console.log(stdout);
|
1101
|
+
* });
|
1102
|
+
* ```
|
1103
|
+
*
|
1104
|
+
* The `stdout` and `stderr` arguments passed to the callback will contain the
|
1105
|
+
* stdout and stderr output of the child process. By default, Node.js will decode
|
1106
|
+
* the output as UTF-8 and pass strings to the callback. The `encoding` option
|
1107
|
+
* can be used to specify the character encoding used to decode the stdout and
|
1108
|
+
* stderr output. If `encoding` is `'buffer'`, or an unrecognized character
|
1109
|
+
* encoding, `Buffer` objects will be passed to the callback instead.
|
1110
|
+
*
|
1111
|
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
1112
|
+
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
1113
|
+
* case of an error (including any error resulting in an exit code other than 0), a
|
1114
|
+
* rejected promise is returned, with the same `error` object given in the
|
1115
|
+
* callback, but with two additional properties `stdout` and `stderr`.
|
1116
|
+
*
|
1117
|
+
* ```js
|
1118
|
+
* const util = require('node:util');
|
1119
|
+
* const execFile = util.promisify(require('node:child_process').execFile);
|
1120
|
+
* async function getVersion() {
|
1121
|
+
* const { stdout } = await execFile('node', ['--version']);
|
1122
|
+
* console.log(stdout);
|
1123
|
+
* }
|
1124
|
+
* getVersion();
|
1125
|
+
* ```
|
1126
|
+
*
|
1127
|
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1128
|
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1129
|
+
* **arbitrary command execution.**
|
1130
|
+
*
|
1131
|
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
1132
|
+
* the error passed to the callback will be an `AbortError`:
|
1133
|
+
*
|
1134
|
+
* ```js
|
1135
|
+
* const { execFile } = require('node:child_process');
|
1136
|
+
* const controller = new AbortController();
|
1137
|
+
* const { signal } = controller;
|
1138
|
+
* const child = execFile('node', ['--version'], { signal }, (error) => {
|
1139
|
+
* console.error(error); // an AbortError
|
1140
|
+
* });
|
1141
|
+
* controller.abort();
|
1142
|
+
* ```
|
1143
|
+
* @since v0.1.91
|
1144
|
+
* @param file The name or path of the executable file to run.
|
1145
|
+
* @param args List of string arguments.
|
1146
|
+
* @param callback Called with the output when process terminates.
|
1147
|
+
*/
|
1148
|
+
function execFile(file: string): ChildProcess;
|
1149
|
+
function execFile(
|
1150
|
+
file: string,
|
1151
|
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1152
|
+
): ChildProcess;
|
1153
|
+
function execFile(file: string, args?: readonly string[] | null): ChildProcess;
|
1154
|
+
function execFile(
|
1155
|
+
file: string,
|
1156
|
+
args: readonly string[] | undefined | null,
|
1157
|
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1158
|
+
): ChildProcess;
|
1159
|
+
// no `options` definitely means stdout/stderr are `string`.
|
1160
|
+
function execFile(
|
1161
|
+
file: string,
|
1162
|
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1163
|
+
): ChildProcess;
|
1164
|
+
function execFile(
|
1165
|
+
file: string,
|
1166
|
+
args: readonly string[] | undefined | null,
|
1167
|
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1168
|
+
): ChildProcess;
|
1169
|
+
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
|
1170
|
+
function execFile(
|
1171
|
+
file: string,
|
1172
|
+
options: ExecFileOptionsWithBufferEncoding,
|
1173
|
+
callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
|
1174
|
+
): ChildProcess;
|
1175
|
+
function execFile(
|
1176
|
+
file: string,
|
1177
|
+
args: readonly string[] | undefined | null,
|
1178
|
+
options: ExecFileOptionsWithBufferEncoding,
|
1179
|
+
callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
|
1180
|
+
): ChildProcess;
|
1181
|
+
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
|
1182
|
+
function execFile(
|
1183
|
+
file: string,
|
1184
|
+
options: ExecFileOptionsWithStringEncoding,
|
1185
|
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1186
|
+
): ChildProcess;
|
1187
|
+
function execFile(
|
1188
|
+
file: string,
|
1189
|
+
args: readonly string[] | undefined | null,
|
1190
|
+
options: ExecFileOptionsWithStringEncoding,
|
1191
|
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1192
|
+
): ChildProcess;
|
1193
|
+
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
|
1194
|
+
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
|
1195
|
+
function execFile(
|
1196
|
+
file: string,
|
1197
|
+
options: ExecFileOptionsWithOtherEncoding,
|
1198
|
+
callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1199
|
+
): ChildProcess;
|
1200
|
+
function execFile(
|
1201
|
+
file: string,
|
1202
|
+
args: readonly string[] | undefined | null,
|
1203
|
+
options: ExecFileOptionsWithOtherEncoding,
|
1204
|
+
callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1205
|
+
): ChildProcess;
|
1206
|
+
// `options` without an `encoding` means stdout/stderr are definitely `string`.
|
1207
|
+
function execFile(
|
1208
|
+
file: string,
|
1209
|
+
options: ExecFileOptions,
|
1210
|
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1211
|
+
): ChildProcess;
|
1212
|
+
function execFile(
|
1213
|
+
file: string,
|
1214
|
+
args: readonly string[] | undefined | null,
|
1215
|
+
options: ExecFileOptions,
|
1216
|
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1217
|
+
): ChildProcess;
|
1218
|
+
// fallback if nothing else matches. Worst case is always `string | Buffer`.
|
1219
|
+
function execFile(
|
1220
|
+
file: string,
|
1221
|
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1222
|
+
callback:
|
1223
|
+
| ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void)
|
1224
|
+
| undefined
|
1225
|
+
| null,
|
1226
|
+
): ChildProcess;
|
1227
|
+
function execFile(
|
1228
|
+
file: string,
|
1229
|
+
args: readonly string[] | undefined | null,
|
1230
|
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1231
|
+
callback:
|
1232
|
+
| ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void)
|
1233
|
+
| undefined
|
1234
|
+
| null,
|
1235
|
+
): ChildProcess;
|
1236
|
+
namespace execFile {
|
1237
|
+
function __promisify__(file: string): PromiseWithChild<{
|
1238
|
+
stdout: string;
|
1239
|
+
stderr: string;
|
1240
|
+
}>;
|
1241
|
+
function __promisify__(
|
1242
|
+
file: string,
|
1243
|
+
args: readonly string[] | undefined | null,
|
1244
|
+
): PromiseWithChild<{
|
1245
|
+
stdout: string;
|
1246
|
+
stderr: string;
|
1247
|
+
}>;
|
1248
|
+
function __promisify__(
|
1249
|
+
file: string,
|
1250
|
+
options: ExecFileOptionsWithBufferEncoding,
|
1251
|
+
): PromiseWithChild<{
|
1252
|
+
stdout: Buffer;
|
1253
|
+
stderr: Buffer;
|
1254
|
+
}>;
|
1255
|
+
function __promisify__(
|
1256
|
+
file: string,
|
1257
|
+
args: readonly string[] | undefined | null,
|
1258
|
+
options: ExecFileOptionsWithBufferEncoding,
|
1259
|
+
): PromiseWithChild<{
|
1260
|
+
stdout: Buffer;
|
1261
|
+
stderr: Buffer;
|
1262
|
+
}>;
|
1263
|
+
function __promisify__(
|
1264
|
+
file: string,
|
1265
|
+
options: ExecFileOptionsWithStringEncoding,
|
1266
|
+
): PromiseWithChild<{
|
1267
|
+
stdout: string;
|
1268
|
+
stderr: string;
|
1269
|
+
}>;
|
1270
|
+
function __promisify__(
|
1271
|
+
file: string,
|
1272
|
+
args: readonly string[] | undefined | null,
|
1273
|
+
options: ExecFileOptionsWithStringEncoding,
|
1274
|
+
): PromiseWithChild<{
|
1275
|
+
stdout: string;
|
1276
|
+
stderr: string;
|
1277
|
+
}>;
|
1278
|
+
function __promisify__(
|
1279
|
+
file: string,
|
1280
|
+
options: ExecFileOptionsWithOtherEncoding,
|
1281
|
+
): PromiseWithChild<{
|
1282
|
+
stdout: string | Buffer;
|
1283
|
+
stderr: string | Buffer;
|
1284
|
+
}>;
|
1285
|
+
function __promisify__(
|
1286
|
+
file: string,
|
1287
|
+
args: readonly string[] | undefined | null,
|
1288
|
+
options: ExecFileOptionsWithOtherEncoding,
|
1289
|
+
): PromiseWithChild<{
|
1290
|
+
stdout: string | Buffer;
|
1291
|
+
stderr: string | Buffer;
|
1292
|
+
}>;
|
1293
|
+
function __promisify__(
|
1294
|
+
file: string,
|
1295
|
+
options: ExecFileOptions,
|
1296
|
+
): PromiseWithChild<{
|
1297
|
+
stdout: string;
|
1298
|
+
stderr: string;
|
1299
|
+
}>;
|
1300
|
+
function __promisify__(
|
1301
|
+
file: string,
|
1302
|
+
args: readonly string[] | undefined | null,
|
1303
|
+
options: ExecFileOptions,
|
1304
|
+
): PromiseWithChild<{
|
1305
|
+
stdout: string;
|
1306
|
+
stderr: string;
|
1307
|
+
}>;
|
1308
|
+
function __promisify__(
|
1309
|
+
file: string,
|
1310
|
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1311
|
+
): PromiseWithChild<{
|
1312
|
+
stdout: string | Buffer;
|
1313
|
+
stderr: string | Buffer;
|
1314
|
+
}>;
|
1315
|
+
function __promisify__(
|
1316
|
+
file: string,
|
1317
|
+
args: readonly string[] | undefined | null,
|
1318
|
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1319
|
+
): PromiseWithChild<{
|
1320
|
+
stdout: string | Buffer;
|
1321
|
+
stderr: string | Buffer;
|
1322
|
+
}>;
|
1323
|
+
}
|
1324
|
+
interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
|
1325
|
+
execPath?: string | undefined;
|
1326
|
+
execArgv?: string[] | undefined;
|
1327
|
+
silent?: boolean | undefined;
|
1328
|
+
/**
|
1329
|
+
* Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
|
1330
|
+
* If passed as an array, the first element is used for `stdin`, the second for
|
1331
|
+
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
1332
|
+
* specify the `stdio` behavior beyond the standard streams. See
|
1333
|
+
* {@link ChildProcess.stdio} for more information.
|
1334
|
+
*
|
1335
|
+
* @default 'pipe'
|
1336
|
+
*/
|
1337
|
+
stdio?: StdioOptions | undefined;
|
1338
|
+
detached?: boolean | undefined;
|
1339
|
+
windowsVerbatimArguments?: boolean | undefined;
|
1340
|
+
}
|
1341
|
+
/**
|
1342
|
+
* The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes.
|
1343
|
+
* Like {@link spawn}, a `ChildProcess` object is returned. The
|
1344
|
+
* returned `ChildProcess` will have an additional communication channel
|
1345
|
+
* built-in that allows messages to be passed back and forth between the parent and
|
1346
|
+
* child. See `subprocess.send()` for details.
|
1347
|
+
*
|
1348
|
+
* Keep in mind that spawned Node.js child processes are
|
1349
|
+
* independent of the parent with exception of the IPC communication channel
|
1350
|
+
* that is established between the two. Each process has its own memory, with
|
1351
|
+
* their own V8 instances. Because of the additional resource allocations
|
1352
|
+
* required, spawning a large number of child Node.js processes is not
|
1353
|
+
* recommended.
|
1354
|
+
*
|
1355
|
+
* 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
|
1356
|
+
* execution path to be used.
|
1357
|
+
*
|
1358
|
+
* Node.js processes launched with a custom `execPath` will communicate with the
|
1359
|
+
* parent process using the file descriptor (fd) identified using the
|
1360
|
+
* environment variable `NODE_CHANNEL_FD` on the child process.
|
1361
|
+
*
|
1362
|
+
* Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
|
1363
|
+
* current process.
|
1364
|
+
*
|
1365
|
+
* The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set.
|
1366
|
+
*
|
1367
|
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
1368
|
+
* the error passed to the callback will be an `AbortError`:
|
1369
|
+
*
|
1370
|
+
* ```js
|
1371
|
+
* if (process.argv[2] === 'child') {
|
1372
|
+
* setTimeout(() => {
|
1373
|
+
* console.log(`Hello from ${process.argv[2]}!`);
|
1374
|
+
* }, 1_000);
|
1375
|
+
* } else {
|
1376
|
+
* const { fork } = require('node:child_process');
|
1377
|
+
* const controller = new AbortController();
|
1378
|
+
* const { signal } = controller;
|
1379
|
+
* const child = fork(__filename, ['child'], { signal });
|
1380
|
+
* child.on('error', (err) => {
|
1381
|
+
* // This will be called with err being an AbortError if the controller aborts
|
1382
|
+
* });
|
1383
|
+
* controller.abort(); // Stops the child process
|
1384
|
+
* }
|
1385
|
+
* ```
|
1386
|
+
* @since v0.5.0
|
1387
|
+
* @param modulePath The module to run in the child.
|
1388
|
+
* @param args List of string arguments.
|
1389
|
+
*/
|
1390
|
+
function fork(modulePath: string, options?: ForkOptions): ChildProcess;
|
1391
|
+
function fork(modulePath: string, args?: readonly string[], options?: ForkOptions): ChildProcess;
|
1392
|
+
interface SpawnSyncOptions extends CommonSpawnOptions {
|
1393
|
+
input?: string | NodeJS.ArrayBufferView | undefined;
|
1394
|
+
maxBuffer?: number | undefined;
|
1395
|
+
encoding?: BufferEncoding | "buffer" | null | undefined;
|
1396
|
+
}
|
1397
|
+
interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
|
1398
|
+
encoding: BufferEncoding;
|
1399
|
+
}
|
1400
|
+
interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
|
1401
|
+
encoding?: "buffer" | null | undefined;
|
1402
|
+
}
|
1403
|
+
interface SpawnSyncReturns<T> {
|
1404
|
+
pid: number;
|
1405
|
+
output: Array<T | null>;
|
1406
|
+
stdout: T;
|
1407
|
+
stderr: T;
|
1408
|
+
status: number | null;
|
1409
|
+
signal: NodeJS.Signals | null;
|
1410
|
+
error?: Error | undefined;
|
1411
|
+
}
|
1412
|
+
/**
|
1413
|
+
* The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
|
1414
|
+
* until the child process has fully closed. When a timeout has been encountered
|
1415
|
+
* and `killSignal` is sent, the method won't return until the process has
|
1416
|
+
* completely exited. If the process intercepts and handles the `SIGTERM` signal
|
1417
|
+
* and doesn't exit, the parent process will wait until the child process has
|
1418
|
+
* exited.
|
1419
|
+
*
|
1420
|
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1421
|
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1422
|
+
* **arbitrary command execution.**
|
1423
|
+
* @since v0.11.12
|
1424
|
+
* @param command The command to run.
|
1425
|
+
* @param args List of string arguments.
|
1426
|
+
*/
|
1427
|
+
function spawnSync(command: string): SpawnSyncReturns<Buffer>;
|
1428
|
+
function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
|
1429
|
+
function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
|
1430
|
+
function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
|
1431
|
+
function spawnSync(command: string, args: readonly string[]): SpawnSyncReturns<Buffer>;
|
1432
|
+
function spawnSync(
|
1433
|
+
command: string,
|
1434
|
+
args: readonly string[],
|
1435
|
+
options: SpawnSyncOptionsWithStringEncoding,
|
1436
|
+
): SpawnSyncReturns<string>;
|
1437
|
+
function spawnSync(
|
1438
|
+
command: string,
|
1439
|
+
args: readonly string[],
|
1440
|
+
options: SpawnSyncOptionsWithBufferEncoding,
|
1441
|
+
): SpawnSyncReturns<Buffer>;
|
1442
|
+
function spawnSync(
|
1443
|
+
command: string,
|
1444
|
+
args?: readonly string[],
|
1445
|
+
options?: SpawnSyncOptions,
|
1446
|
+
): SpawnSyncReturns<string | Buffer>;
|
1447
|
+
interface CommonExecOptions extends CommonOptions {
|
1448
|
+
input?: string | NodeJS.ArrayBufferView | undefined;
|
1449
|
+
/**
|
1450
|
+
* Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings.
|
1451
|
+
* If passed as an array, the first element is used for `stdin`, the second for
|
1452
|
+
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
1453
|
+
* specify the `stdio` behavior beyond the standard streams. See
|
1454
|
+
* {@link ChildProcess.stdio} for more information.
|
1455
|
+
*
|
1456
|
+
* @default 'pipe'
|
1457
|
+
*/
|
1458
|
+
stdio?: StdioOptions | undefined;
|
1459
|
+
killSignal?: NodeJS.Signals | number | undefined;
|
1460
|
+
maxBuffer?: number | undefined;
|
1461
|
+
encoding?: BufferEncoding | "buffer" | null | undefined;
|
1462
|
+
}
|
1463
|
+
interface ExecSyncOptions extends CommonExecOptions {
|
1464
|
+
shell?: string | undefined;
|
1465
|
+
}
|
1466
|
+
interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
|
1467
|
+
encoding: BufferEncoding;
|
1468
|
+
}
|
1469
|
+
interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
|
1470
|
+
encoding?: "buffer" | null | undefined;
|
1471
|
+
}
|
1472
|
+
/**
|
1473
|
+
* The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return
|
1474
|
+
* until the child process has fully closed. When a timeout has been encountered
|
1475
|
+
* and `killSignal` is sent, the method won't return until the process has
|
1476
|
+
* 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
|
1477
|
+
* has exited.
|
1478
|
+
*
|
1479
|
+
* If the process times out or has a non-zero exit code, this method will throw.
|
1480
|
+
* The `Error` object will contain the entire result from {@link spawnSync}.
|
1481
|
+
*
|
1482
|
+
* **Never pass unsanitized user input to this function. Any input containing shell**
|
1483
|
+
* **metacharacters may be used to trigger arbitrary command execution.**
|
1484
|
+
* @since v0.11.12
|
1485
|
+
* @param command The command to run.
|
1486
|
+
* @return The stdout from the command.
|
1487
|
+
*/
|
1488
|
+
function execSync(command: string): Buffer;
|
1489
|
+
function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string;
|
1490
|
+
function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer;
|
1491
|
+
function execSync(command: string, options?: ExecSyncOptions): string | Buffer;
|
1492
|
+
interface ExecFileSyncOptions extends CommonExecOptions {
|
1493
|
+
shell?: boolean | string | undefined;
|
1494
|
+
}
|
1495
|
+
interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
|
1496
|
+
encoding: BufferEncoding;
|
1497
|
+
}
|
1498
|
+
interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
|
1499
|
+
encoding?: "buffer" | null; // specify `null`.
|
1500
|
+
}
|
1501
|
+
/**
|
1502
|
+
* The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not
|
1503
|
+
* return until the child process has fully closed. When a timeout has been
|
1504
|
+
* encountered and `killSignal` is sent, the method won't return until the process
|
1505
|
+
* has completely exited.
|
1506
|
+
*
|
1507
|
+
* If the child process intercepts and handles the `SIGTERM` signal and
|
1508
|
+
* does not exit, the parent process will still wait until the child process has
|
1509
|
+
* exited.
|
1510
|
+
*
|
1511
|
+
* 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}.
|
1512
|
+
*
|
1513
|
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1514
|
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1515
|
+
* **arbitrary command execution.**
|
1516
|
+
* @since v0.11.12
|
1517
|
+
* @param file The name or path of the executable file to run.
|
1518
|
+
* @param args List of string arguments.
|
1519
|
+
* @return The stdout from the command.
|
1520
|
+
*/
|
1521
|
+
function execFileSync(file: string): Buffer;
|
1522
|
+
function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string;
|
1523
|
+
function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
|
1524
|
+
function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer;
|
1525
|
+
function execFileSync(file: string, args: readonly string[]): Buffer;
|
1526
|
+
function execFileSync(
|
1527
|
+
file: string,
|
1528
|
+
args: readonly string[],
|
1529
|
+
options: ExecFileSyncOptionsWithStringEncoding,
|
1530
|
+
): string;
|
1531
|
+
function execFileSync(
|
1532
|
+
file: string,
|
1533
|
+
args: readonly string[],
|
1534
|
+
options: ExecFileSyncOptionsWithBufferEncoding,
|
1535
|
+
): Buffer;
|
1536
|
+
function execFileSync(file: string, args?: readonly string[], options?: ExecFileSyncOptions): string | Buffer;
|
1537
|
+
}
|
1538
|
+
declare module "node:child_process" {
|
1539
|
+
export * from "child_process";
|
1540
|
+
}
|