@kubb/agent 4.28.0 → 4.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +382 -642
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +4 -6
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +4 -6
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@kubb/fabric-core/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
- package/.output/server/node_modules/@kubb/fabric-core/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +8 -9
- package/.output/server/node_modules/@kubb/fabric-core/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +3 -4
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +2 -3
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +58 -298
- package/.output/server/node_modules/@kubb/fabric-core/package.json +8 -18
- package/.output/server/node_modules/@kubb/react-fabric/dist/{chunk-DbZtQ4qb.js → chunk-Cnw5r_-A.js} +1 -5
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +39 -41
- package/.output/server/node_modules/@kubb/react-fabric/dist/{jsx-runtime-CQFBnRKx.js → jsx-runtime-Dm7PKVbc.js} +6 -24
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +5 -4
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +3 -3
- package/.output/server/node_modules/@kubb/react-fabric/dist/{react--draJ5Pm.js → react-D652OKii.js} +31 -91
- package/.output/server/node_modules/@kubb/react-fabric/dist/{reactPlugin-DqJsInTf.js → reactPlugin-BkDkx1cs.js} +410 -1650
- package/.output/server/node_modules/@kubb/react-fabric/package.json +8 -11
- package/.output/server/node_modules/empathic/access.js +39 -0
- package/.output/server/node_modules/empathic/access.mjs +34 -0
- package/.output/server/node_modules/empathic/find.js +81 -0
- package/.output/server/node_modules/empathic/find.mjs +76 -0
- package/.output/server/node_modules/empathic/package.json +49 -0
- package/.output/server/node_modules/empathic/package.mjs +52 -0
- package/.output/server/node_modules/empathic/resolve.js +31 -0
- package/.output/server/node_modules/empathic/resolve.mjs +27 -0
- package/.output/server/node_modules/empathic/walk.js +22 -0
- package/.output/server/node_modules/empathic/walk.mjs +20 -0
- package/.output/server/node_modules/tinyexec/dist/main.js +633 -0
- package/.output/server/node_modules/tinyexec/package.json +61 -0
- package/.output/server/package.json +6 -44
- package/package.json +19 -21
- package/.output/server/node_modules/.nitro/path-key@3.1.1/index.js +0 -16
- package/.output/server/node_modules/.nitro/path-key@3.1.1/package.json +0 -39
- package/.output/server/node_modules/.nitro/path-key@4.0.0/index.js +0 -12
- package/.output/server/node_modules/.nitro/path-key@4.0.0/package.json +0 -41
- package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/index.js +0 -421
- package/.output/server/node_modules/.nitro/path-to-regexp@3.3.0/package.json +0 -46
- package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-BVHe6Par.js +0 -22
- package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.js +0 -89
- package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/fromAnyIterable.js +0 -34
- package/.output/server/node_modules/@sec-ant/readable-stream/dist/ponyfill/index.js +0 -6
- package/.output/server/node_modules/@sec-ant/readable-stream/package.json +0 -98
- package/.output/server/node_modules/@sindresorhus/merge-streams/index.js +0 -265
- package/.output/server/node_modules/@sindresorhus/merge-streams/package.json +0 -49
- package/.output/server/node_modules/balanced-match/index.js +0 -62
- package/.output/server/node_modules/balanced-match/package.json +0 -48
- package/.output/server/node_modules/brace-expansion/index.js +0 -201
- package/.output/server/node_modules/brace-expansion/package.json +0 -50
- package/.output/server/node_modules/bytes/index.js +0 -159
- package/.output/server/node_modules/bytes/package.json +0 -39
- package/.output/server/node_modules/concat-map/index.js +0 -13
- package/.output/server/node_modules/concat-map/package.json +0 -59
- package/.output/server/node_modules/content-disposition/index.js +0 -445
- package/.output/server/node_modules/content-disposition/package.json +0 -39
- package/.output/server/node_modules/cross-spawn/index.js +0 -39
- package/.output/server/node_modules/cross-spawn/lib/enoent.js +0 -59
- package/.output/server/node_modules/cross-spawn/lib/parse.js +0 -91
- package/.output/server/node_modules/cross-spawn/lib/util/escape.js +0 -47
- package/.output/server/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
- package/.output/server/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
- package/.output/server/node_modules/cross-spawn/package.json +0 -73
- package/.output/server/node_modules/execa/index.js +0 -28
- package/.output/server/node_modules/execa/lib/arguments/command.js +0 -20
- package/.output/server/node_modules/execa/lib/arguments/cwd.js +0 -39
- package/.output/server/node_modules/execa/lib/arguments/encoding-option.js +0 -50
- package/.output/server/node_modules/execa/lib/arguments/escape.js +0 -88
- package/.output/server/node_modules/execa/lib/arguments/fd-options.js +0 -108
- package/.output/server/node_modules/execa/lib/arguments/file-url.js +0 -25
- package/.output/server/node_modules/execa/lib/arguments/options.js +0 -96
- package/.output/server/node_modules/execa/lib/arguments/shell.js +0 -11
- package/.output/server/node_modules/execa/lib/arguments/specific.js +0 -111
- package/.output/server/node_modules/execa/lib/convert/add.js +0 -15
- package/.output/server/node_modules/execa/lib/convert/concurrent.js +0 -33
- package/.output/server/node_modules/execa/lib/convert/duplex.js +0 -69
- package/.output/server/node_modules/execa/lib/convert/iterable.js +0 -34
- package/.output/server/node_modules/execa/lib/convert/readable.js +0 -113
- package/.output/server/node_modules/execa/lib/convert/shared.js +0 -46
- package/.output/server/node_modules/execa/lib/convert/writable.js +0 -90
- package/.output/server/node_modules/execa/lib/io/contents.js +0 -116
- package/.output/server/node_modules/execa/lib/io/input-sync.js +0 -44
- package/.output/server/node_modules/execa/lib/io/iterate.js +0 -110
- package/.output/server/node_modules/execa/lib/io/max-buffer.js +0 -89
- package/.output/server/node_modules/execa/lib/io/output-async.js +0 -80
- package/.output/server/node_modules/execa/lib/io/output-sync.js +0 -135
- package/.output/server/node_modules/execa/lib/io/pipeline.js +0 -48
- package/.output/server/node_modules/execa/lib/io/strip-newline.js +0 -12
- package/.output/server/node_modules/execa/lib/ipc/array.js +0 -4
- package/.output/server/node_modules/execa/lib/ipc/buffer-messages.js +0 -47
- package/.output/server/node_modules/execa/lib/ipc/forward.js +0 -56
- package/.output/server/node_modules/execa/lib/ipc/get-each.js +0 -89
- package/.output/server/node_modules/execa/lib/ipc/get-one.js +0 -69
- package/.output/server/node_modules/execa/lib/ipc/graceful.js +0 -72
- package/.output/server/node_modules/execa/lib/ipc/incoming.js +0 -79
- package/.output/server/node_modules/execa/lib/ipc/ipc-input.js +0 -44
- package/.output/server/node_modules/execa/lib/ipc/methods.js +0 -49
- package/.output/server/node_modules/execa/lib/ipc/outgoing.js +0 -47
- package/.output/server/node_modules/execa/lib/ipc/reference.js +0 -44
- package/.output/server/node_modules/execa/lib/ipc/send.js +0 -91
- package/.output/server/node_modules/execa/lib/ipc/strict.js +0 -113
- package/.output/server/node_modules/execa/lib/ipc/validation.js +0 -111
- package/.output/server/node_modules/execa/lib/methods/bind.js +0 -23
- package/.output/server/node_modules/execa/lib/methods/command.js +0 -43
- package/.output/server/node_modules/execa/lib/methods/create.js +0 -65
- package/.output/server/node_modules/execa/lib/methods/main-async.js +0 -194
- package/.output/server/node_modules/execa/lib/methods/main-sync.js +0 -163
- package/.output/server/node_modules/execa/lib/methods/node.js +0 -51
- package/.output/server/node_modules/execa/lib/methods/parameters.js +0 -31
- package/.output/server/node_modules/execa/lib/methods/promise.js +0 -15
- package/.output/server/node_modules/execa/lib/methods/script.js +0 -22
- package/.output/server/node_modules/execa/lib/methods/template.js +0 -153
- package/.output/server/node_modules/execa/lib/pipe/abort.js +0 -20
- package/.output/server/node_modules/execa/lib/pipe/pipe-arguments.js +0 -91
- package/.output/server/node_modules/execa/lib/pipe/sequence.js +0 -24
- package/.output/server/node_modules/execa/lib/pipe/setup.js +0 -72
- package/.output/server/node_modules/execa/lib/pipe/streaming.js +0 -51
- package/.output/server/node_modules/execa/lib/pipe/throw.js +0 -58
- package/.output/server/node_modules/execa/lib/resolve/all-async.js +0 -46
- package/.output/server/node_modules/execa/lib/resolve/all-sync.js +0 -33
- package/.output/server/node_modules/execa/lib/resolve/exit-async.js +0 -54
- package/.output/server/node_modules/execa/lib/resolve/exit-sync.js +0 -25
- package/.output/server/node_modules/execa/lib/resolve/stdio.js +0 -47
- package/.output/server/node_modules/execa/lib/resolve/wait-stream.js +0 -96
- package/.output/server/node_modules/execa/lib/resolve/wait-subprocess.js +0 -146
- package/.output/server/node_modules/execa/lib/return/duration.js +0 -8
- package/.output/server/node_modules/execa/lib/return/early-error.js +0 -60
- package/.output/server/node_modules/execa/lib/return/final-error.js +0 -40
- package/.output/server/node_modules/execa/lib/return/message.js +0 -157
- package/.output/server/node_modules/execa/lib/return/reject.js +0 -13
- package/.output/server/node_modules/execa/lib/return/result.js +0 -186
- package/.output/server/node_modules/execa/lib/stdio/direction.js +0 -76
- package/.output/server/node_modules/execa/lib/stdio/duplicate.js +0 -116
- package/.output/server/node_modules/execa/lib/stdio/handle-async.js +0 -52
- package/.output/server/node_modules/execa/lib/stdio/handle-sync.js +0 -57
- package/.output/server/node_modules/execa/lib/stdio/handle.js +0 -214
- package/.output/server/node_modules/execa/lib/stdio/input-option.js +0 -50
- package/.output/server/node_modules/execa/lib/stdio/native.js +0 -106
- package/.output/server/node_modules/execa/lib/stdio/stdio-option.js +0 -60
- package/.output/server/node_modules/execa/lib/stdio/type.js +0 -173
- package/.output/server/node_modules/execa/lib/terminate/cancel.js +0 -20
- package/.output/server/node_modules/execa/lib/terminate/cleanup.js +0 -16
- package/.output/server/node_modules/execa/lib/terminate/graceful.js +0 -71
- package/.output/server/node_modules/execa/lib/terminate/kill.js +0 -93
- package/.output/server/node_modules/execa/lib/terminate/signal.js +0 -70
- package/.output/server/node_modules/execa/lib/terminate/timeout.js +0 -21
- package/.output/server/node_modules/execa/lib/transform/encoding-transform.js +0 -51
- package/.output/server/node_modules/execa/lib/transform/generator.js +0 -107
- package/.output/server/node_modules/execa/lib/transform/normalize.js +0 -111
- package/.output/server/node_modules/execa/lib/transform/object-mode.js +0 -41
- package/.output/server/node_modules/execa/lib/transform/run-async.js +0 -60
- package/.output/server/node_modules/execa/lib/transform/run-sync.js +0 -50
- package/.output/server/node_modules/execa/lib/transform/split.js +0 -110
- package/.output/server/node_modules/execa/lib/transform/validate.js +0 -43
- package/.output/server/node_modules/execa/lib/utils/abort-signal.js +0 -8
- package/.output/server/node_modules/execa/lib/utils/deferred.js +0 -7
- package/.output/server/node_modules/execa/lib/utils/max-listeners.js +0 -14
- package/.output/server/node_modules/execa/lib/utils/standard-stream.js +0 -6
- package/.output/server/node_modules/execa/lib/utils/uint-array.js +0 -69
- package/.output/server/node_modules/execa/lib/verbose/complete.js +0 -24
- package/.output/server/node_modules/execa/lib/verbose/custom.js +0 -26
- package/.output/server/node_modules/execa/lib/verbose/default.js +0 -54
- package/.output/server/node_modules/execa/lib/verbose/error.js +0 -13
- package/.output/server/node_modules/execa/lib/verbose/info.js +0 -39
- package/.output/server/node_modules/execa/lib/verbose/ipc.js +0 -15
- package/.output/server/node_modules/execa/lib/verbose/log.js +0 -54
- package/.output/server/node_modules/execa/lib/verbose/output.js +0 -60
- package/.output/server/node_modules/execa/lib/verbose/start.js +0 -15
- package/.output/server/node_modules/execa/lib/verbose/values.js +0 -33
- package/.output/server/node_modules/execa/package.json +0 -105
- package/.output/server/node_modules/figures/index.js +0 -292
- package/.output/server/node_modules/figures/package.json +0 -49
- package/.output/server/node_modules/fs-extra/lib/copy/copy-sync.js +0 -176
- package/.output/server/node_modules/fs-extra/lib/copy/copy.js +0 -180
- package/.output/server/node_modules/fs-extra/lib/copy/index.js +0 -7
- package/.output/server/node_modules/fs-extra/lib/empty/index.js +0 -39
- package/.output/server/node_modules/fs-extra/lib/ensure/file.js +0 -66
- package/.output/server/node_modules/fs-extra/lib/ensure/index.js +0 -23
- package/.output/server/node_modules/fs-extra/lib/ensure/link.js +0 -64
- package/.output/server/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
- package/.output/server/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
- package/.output/server/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
- package/.output/server/node_modules/fs-extra/lib/fs/index.js +0 -146
- package/.output/server/node_modules/fs-extra/lib/index.js +0 -16
- package/.output/server/node_modules/fs-extra/lib/json/index.js +0 -16
- package/.output/server/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
- package/.output/server/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
- package/.output/server/node_modules/fs-extra/lib/json/output-json.js +0 -12
- package/.output/server/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
- package/.output/server/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
- package/.output/server/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
- package/.output/server/node_modules/fs-extra/lib/move/index.js +0 -7
- package/.output/server/node_modules/fs-extra/lib/move/move-sync.js +0 -55
- package/.output/server/node_modules/fs-extra/lib/move/move.js +0 -59
- package/.output/server/node_modules/fs-extra/lib/output-file/index.js +0 -31
- package/.output/server/node_modules/fs-extra/lib/path-exists/index.js +0 -12
- package/.output/server/node_modules/fs-extra/lib/remove/index.js +0 -17
- package/.output/server/node_modules/fs-extra/lib/util/async.js +0 -29
- package/.output/server/node_modules/fs-extra/lib/util/stat.js +0 -159
- package/.output/server/node_modules/fs-extra/lib/util/utimes.js +0 -36
- package/.output/server/node_modules/fs-extra/package.json +0 -71
- package/.output/server/node_modules/get-stream/package.json +0 -60
- package/.output/server/node_modules/get-stream/source/array-buffer.js +0 -84
- package/.output/server/node_modules/get-stream/source/array.js +0 -32
- package/.output/server/node_modules/get-stream/source/buffer.js +0 -19
- package/.output/server/node_modules/get-stream/source/contents.js +0 -121
- package/.output/server/node_modules/get-stream/source/exports.js +0 -5
- package/.output/server/node_modules/get-stream/source/index.js +0 -13
- package/.output/server/node_modules/get-stream/source/stream.js +0 -65
- package/.output/server/node_modules/get-stream/source/string.js +0 -41
- package/.output/server/node_modules/get-stream/source/utils.js +0 -11
- package/.output/server/node_modules/graceful-fs/clone.js +0 -23
- package/.output/server/node_modules/graceful-fs/graceful-fs.js +0 -448
- package/.output/server/node_modules/graceful-fs/legacy-streams.js +0 -118
- package/.output/server/node_modules/graceful-fs/package.json +0 -53
- package/.output/server/node_modules/graceful-fs/polyfills.js +0 -355
- package/.output/server/node_modules/human-signals/build/src/core.js +0 -273
- package/.output/server/node_modules/human-signals/build/src/main.js +0 -70
- package/.output/server/node_modules/human-signals/build/src/realtime.js +0 -16
- package/.output/server/node_modules/human-signals/build/src/signals.js +0 -34
- package/.output/server/node_modules/human-signals/package.json +0 -66
- package/.output/server/node_modules/is-plain-obj/index.js +0 -8
- package/.output/server/node_modules/is-plain-obj/package.json +0 -41
- package/.output/server/node_modules/is-stream/index.js +0 -37
- package/.output/server/node_modules/is-stream/package.json +0 -48
- package/.output/server/node_modules/is-unicode-supported/index.js +0 -21
- package/.output/server/node_modules/is-unicode-supported/package.json +0 -47
- package/.output/server/node_modules/isexe/index.js +0 -57
- package/.output/server/node_modules/isexe/mode.js +0 -41
- package/.output/server/node_modules/isexe/package.json +0 -31
- package/.output/server/node_modules/isexe/windows.js +0 -42
- package/.output/server/node_modules/js-runtime/dist/index.js +0 -5
- package/.output/server/node_modules/js-runtime/package.json +0 -72
- package/.output/server/node_modules/jsonfile/index.js +0 -88
- package/.output/server/node_modules/jsonfile/package.json +0 -40
- package/.output/server/node_modules/jsonfile/utils.js +0 -14
- package/.output/server/node_modules/mime-db/db.json +0 -7088
- package/.output/server/node_modules/mime-db/index.js +0 -11
- package/.output/server/node_modules/mime-db/package.json +0 -57
- package/.output/server/node_modules/mime-types/index.js +0 -188
- package/.output/server/node_modules/mime-types/package.json +0 -43
- package/.output/server/node_modules/minimatch/minimatch.js +0 -947
- package/.output/server/node_modules/minimatch/package.json +0 -33
- package/.output/server/node_modules/natural-orderby/dist/main.js +0 -19
- package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.development.js +0 -420
- package/.output/server/node_modules/natural-orderby/dist/umd/natural-orderby.production.min.js +0 -11
- package/.output/server/node_modules/natural-orderby/package.json +0 -119
- package/.output/server/node_modules/npm-run-path/index.js +0 -55
- package/.output/server/node_modules/npm-run-path/package.json +0 -52
- package/.output/server/node_modules/parse-ms/index.js +0 -45
- package/.output/server/node_modules/parse-ms/package.json +0 -47
- package/.output/server/node_modules/path-is-inside/lib/path-is-inside.js +0 -28
- package/.output/server/node_modules/path-is-inside/package.json +0 -27
- package/.output/server/node_modules/pretty-ms/index.js +0 -149
- package/.output/server/node_modules/pretty-ms/package.json +0 -55
- package/.output/server/node_modules/range-parser/index.js +0 -158
- package/.output/server/node_modules/range-parser/package.json +0 -40
- package/.output/server/node_modules/serve-handler/package.json +0 -68
- package/.output/server/node_modules/serve-handler/src/directory.js +0 -16
- package/.output/server/node_modules/serve-handler/src/error.js +0 -10
- package/.output/server/node_modules/serve-handler/src/glob-slash.js +0 -9
- package/.output/server/node_modules/serve-handler/src/index.js +0 -769
- package/.output/server/node_modules/shebang-command/index.js +0 -19
- package/.output/server/node_modules/shebang-command/package.json +0 -34
- package/.output/server/node_modules/shebang-regex/index.js +0 -2
- package/.output/server/node_modules/shebang-regex/package.json +0 -35
- package/.output/server/node_modules/signal-exit/dist/mjs/index.js +0 -275
- package/.output/server/node_modules/signal-exit/dist/mjs/package.json +0 -3
- package/.output/server/node_modules/signal-exit/dist/mjs/signals.js +0 -39
- package/.output/server/node_modules/signal-exit/package.json +0 -106
- package/.output/server/node_modules/string-argv/index.js +0 -41
- package/.output/server/node_modules/string-argv/package.json +0 -51
- package/.output/server/node_modules/strip-final-newline/index.js +0 -26
- package/.output/server/node_modules/strip-final-newline/package.json +0 -49
- package/.output/server/node_modules/unicorn-magic/default.js +0 -14
- package/.output/server/node_modules/unicorn-magic/node.js +0 -49
- package/.output/server/node_modules/unicorn-magic/package.json +0 -62
- package/.output/server/node_modules/universalify/index.js +0 -24
- package/.output/server/node_modules/universalify/package.json +0 -34
- package/.output/server/node_modules/which/package.json +0 -43
- package/.output/server/node_modules/which/which.js +0 -125
- package/.output/server/node_modules/yoctocolors/base.js +0 -94
- package/.output/server/node_modules/yoctocolors/index.js +0 -2
- package/.output/server/node_modules/yoctocolors/package.json +0 -69
- /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/dist/index.js +0 -0
- /package/.output/server/node_modules/{.nitro/path-to-regexp@8.3.0 → path-to-regexp}/package.json +0 -0
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {isReadableStream} from 'is-stream';
|
|
2
|
-
import {isUint8Array} from '../utils/uint-array.js';
|
|
3
|
-
import {isUrl, isFilePathString} from './type.js';
|
|
4
|
-
|
|
5
|
-
// Append the `stdin` option with the `input` and `inputFile` options
|
|
6
|
-
export const handleInputOptions = ({input, inputFile}, fdNumber) => fdNumber === 0
|
|
7
|
-
? [
|
|
8
|
-
...handleInputOption(input),
|
|
9
|
-
...handleInputFileOption(inputFile),
|
|
10
|
-
]
|
|
11
|
-
: [];
|
|
12
|
-
|
|
13
|
-
const handleInputOption = input => input === undefined ? [] : [{
|
|
14
|
-
type: getInputType(input),
|
|
15
|
-
value: input,
|
|
16
|
-
optionName: 'input',
|
|
17
|
-
}];
|
|
18
|
-
|
|
19
|
-
const getInputType = input => {
|
|
20
|
-
if (isReadableStream(input, {checkOpen: false})) {
|
|
21
|
-
return 'nodeStream';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (typeof input === 'string') {
|
|
25
|
-
return 'string';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (isUint8Array(input)) {
|
|
29
|
-
return 'uint8Array';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
throw new Error('The `input` option must be a string, a Uint8Array or a Node.js Readable stream.');
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const handleInputFileOption = inputFile => inputFile === undefined ? [] : [{
|
|
36
|
-
...getInputFileType(inputFile),
|
|
37
|
-
optionName: 'inputFile',
|
|
38
|
-
}];
|
|
39
|
-
|
|
40
|
-
const getInputFileType = inputFile => {
|
|
41
|
-
if (isUrl(inputFile)) {
|
|
42
|
-
return {type: 'fileUrl', value: inputFile};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (isFilePathString(inputFile)) {
|
|
46
|
-
return {type: 'filePath', value: {file: inputFile}};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
throw new Error('The `inputFile` option must be a file path string or a file URL.');
|
|
50
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import {readFileSync} from 'node:fs';
|
|
2
|
-
import tty from 'node:tty';
|
|
3
|
-
import {isStream as isNodeStream} from 'is-stream';
|
|
4
|
-
import {STANDARD_STREAMS} from '../utils/standard-stream.js';
|
|
5
|
-
import {bufferToUint8Array} from '../utils/uint-array.js';
|
|
6
|
-
import {serializeOptionValue} from '../arguments/fd-options.js';
|
|
7
|
-
|
|
8
|
-
// When we use multiple `stdio` values for the same streams, we pass 'pipe' to `child_process.spawn()`.
|
|
9
|
-
// We then emulate the piping done by core Node.js.
|
|
10
|
-
// To do so, we transform the following values:
|
|
11
|
-
// - Node.js streams are marked as `type: nodeStream`
|
|
12
|
-
// - 'inherit' becomes `process.stdin|stdout|stderr`
|
|
13
|
-
// - any file descriptor integer becomes `process.stdio[fdNumber]`
|
|
14
|
-
// All of the above transformations tell Execa to perform manual piping.
|
|
15
|
-
export const handleNativeStream = ({stdioItem, stdioItem: {type}, isStdioArray, fdNumber, direction, isSync}) => {
|
|
16
|
-
if (!isStdioArray || type !== 'native') {
|
|
17
|
-
return stdioItem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return isSync
|
|
21
|
-
? handleNativeStreamSync({stdioItem, fdNumber, direction})
|
|
22
|
-
: handleNativeStreamAsync({stdioItem, fdNumber});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Synchronous methods use a different logic.
|
|
26
|
-
// 'inherit', file descriptors and process.std* are handled by readFileSync()/writeFileSync().
|
|
27
|
-
const handleNativeStreamSync = ({stdioItem, stdioItem: {value, optionName}, fdNumber, direction}) => {
|
|
28
|
-
const targetFd = getTargetFd({
|
|
29
|
-
value,
|
|
30
|
-
optionName,
|
|
31
|
-
fdNumber,
|
|
32
|
-
direction,
|
|
33
|
-
});
|
|
34
|
-
if (targetFd !== undefined) {
|
|
35
|
-
return targetFd;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (isNodeStream(value, {checkOpen: false})) {
|
|
39
|
-
throw new TypeError(`The \`${optionName}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return stdioItem;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const getTargetFd = ({value, optionName, fdNumber, direction}) => {
|
|
46
|
-
const targetFdNumber = getTargetFdNumber(value, fdNumber);
|
|
47
|
-
if (targetFdNumber === undefined) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (direction === 'output') {
|
|
52
|
-
return {type: 'fileNumber', value: targetFdNumber, optionName};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (tty.isatty(targetFdNumber)) {
|
|
56
|
-
throw new TypeError(`The \`${optionName}: ${serializeOptionValue(value)}\` option is invalid: it cannot be a TTY with synchronous methods.`);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {type: 'uint8Array', value: bufferToUint8Array(readFileSync(targetFdNumber)), optionName};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const getTargetFdNumber = (value, fdNumber) => {
|
|
63
|
-
if (value === 'inherit') {
|
|
64
|
-
return fdNumber;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (typeof value === 'number') {
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const standardStreamIndex = STANDARD_STREAMS.indexOf(value);
|
|
72
|
-
if (standardStreamIndex !== -1) {
|
|
73
|
-
return standardStreamIndex;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const handleNativeStreamAsync = ({stdioItem, stdioItem: {value, optionName}, fdNumber}) => {
|
|
78
|
-
if (value === 'inherit') {
|
|
79
|
-
return {type: 'nodeStream', value: getStandardStream(fdNumber, value, optionName), optionName};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (typeof value === 'number') {
|
|
83
|
-
return {type: 'nodeStream', value: getStandardStream(value, value, optionName), optionName};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (isNodeStream(value, {checkOpen: false})) {
|
|
87
|
-
return {type: 'nodeStream', value, optionName};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return stdioItem;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
// Node.js does not allow to easily retrieve file descriptors beyond stdin/stdout/stderr as streams.
|
|
94
|
-
// - `fs.createReadStream()`/`fs.createWriteStream()` with the `fd` option do not work with character devices that use blocking reads/writes (such as interactive TTYs).
|
|
95
|
-
// - Using a TCP `Socket` would work but be rather complex to implement.
|
|
96
|
-
// Since this is an edge case, we simply throw an error message.
|
|
97
|
-
// See https://github.com/sindresorhus/execa/pull/643#discussion_r1435905707
|
|
98
|
-
const getStandardStream = (fdNumber, value, optionName) => {
|
|
99
|
-
const standardStream = STANDARD_STREAMS[fdNumber];
|
|
100
|
-
|
|
101
|
-
if (standardStream === undefined) {
|
|
102
|
-
throw new TypeError(`The \`${optionName}: ${value}\` option is invalid: no such standard stream.`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return standardStream;
|
|
106
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {STANDARD_STREAMS_ALIASES} from '../utils/standard-stream.js';
|
|
2
|
-
import {normalizeIpcStdioArray} from '../ipc/array.js';
|
|
3
|
-
import {isFullVerbose} from '../verbose/values.js';
|
|
4
|
-
|
|
5
|
-
// Add support for `stdin`/`stdout`/`stderr` as an alias for `stdio`.
|
|
6
|
-
// Also normalize the `stdio` option.
|
|
7
|
-
export const normalizeStdioOption = ({stdio, ipc, buffer, ...options}, verboseInfo, isSync) => {
|
|
8
|
-
const stdioArray = getStdioArray(stdio, options).map((stdioOption, fdNumber) => addDefaultValue(stdioOption, fdNumber));
|
|
9
|
-
return isSync
|
|
10
|
-
? normalizeStdioSync(stdioArray, buffer, verboseInfo)
|
|
11
|
-
: normalizeIpcStdioArray(stdioArray, ipc);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const getStdioArray = (stdio, options) => {
|
|
15
|
-
if (stdio === undefined) {
|
|
16
|
-
return STANDARD_STREAMS_ALIASES.map(alias => options[alias]);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (hasAlias(options)) {
|
|
20
|
-
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${STANDARD_STREAMS_ALIASES.map(alias => `\`${alias}\``).join(', ')}`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (typeof stdio === 'string') {
|
|
24
|
-
return [stdio, stdio, stdio];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!Array.isArray(stdio)) {
|
|
28
|
-
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const length = Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length);
|
|
32
|
-
return Array.from({length}, (_, fdNumber) => stdio[fdNumber]);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const hasAlias = options => STANDARD_STREAMS_ALIASES.some(alias => options[alias] !== undefined);
|
|
36
|
-
|
|
37
|
-
const addDefaultValue = (stdioOption, fdNumber) => {
|
|
38
|
-
if (Array.isArray(stdioOption)) {
|
|
39
|
-
return stdioOption.map(item => addDefaultValue(item, fdNumber));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (stdioOption === null || stdioOption === undefined) {
|
|
43
|
-
return fdNumber >= STANDARD_STREAMS_ALIASES.length ? 'ignore' : 'pipe';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return stdioOption;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Using `buffer: false` with synchronous methods implies `stdout`/`stderr`: `ignore`.
|
|
50
|
-
// Unless the output is needed, e.g. due to `verbose: 'full'` or to redirecting to a file.
|
|
51
|
-
const normalizeStdioSync = (stdioArray, buffer, verboseInfo) => stdioArray.map((stdioOption, fdNumber) =>
|
|
52
|
-
!buffer[fdNumber]
|
|
53
|
-
&& fdNumber !== 0
|
|
54
|
-
&& !isFullVerbose(verboseInfo, fdNumber)
|
|
55
|
-
&& isOutputPipeOnly(stdioOption)
|
|
56
|
-
? 'ignore'
|
|
57
|
-
: stdioOption);
|
|
58
|
-
|
|
59
|
-
const isOutputPipeOnly = stdioOption => stdioOption === 'pipe'
|
|
60
|
-
|| (Array.isArray(stdioOption) && stdioOption.every(item => item === 'pipe'));
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import {isStream as isNodeStream, isDuplexStream} from 'is-stream';
|
|
2
|
-
import isPlainObj from 'is-plain-obj';
|
|
3
|
-
import {isUint8Array} from '../utils/uint-array.js';
|
|
4
|
-
|
|
5
|
-
// The `stdin`/`stdout`/`stderr` option can be of many types. This detects it.
|
|
6
|
-
export const getStdioItemType = (value, optionName) => {
|
|
7
|
-
if (isAsyncGenerator(value)) {
|
|
8
|
-
return 'asyncGenerator';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (isSyncGenerator(value)) {
|
|
12
|
-
return 'generator';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (isUrl(value)) {
|
|
16
|
-
return 'fileUrl';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (isFilePathObject(value)) {
|
|
20
|
-
return 'filePath';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (isWebStream(value)) {
|
|
24
|
-
return 'webStream';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (isNodeStream(value, {checkOpen: false})) {
|
|
28
|
-
return 'native';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (isUint8Array(value)) {
|
|
32
|
-
return 'uint8Array';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (isAsyncIterableObject(value)) {
|
|
36
|
-
return 'asyncIterable';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (isIterableObject(value)) {
|
|
40
|
-
return 'iterable';
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (isTransformStream(value)) {
|
|
44
|
-
return getTransformStreamType({transform: value}, optionName);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (isTransformOptions(value)) {
|
|
48
|
-
return getTransformObjectType(value, optionName);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return 'native';
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const getTransformObjectType = (value, optionName) => {
|
|
55
|
-
if (isDuplexStream(value.transform, {checkOpen: false})) {
|
|
56
|
-
return getDuplexType(value, optionName);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (isTransformStream(value.transform)) {
|
|
60
|
-
return getTransformStreamType(value, optionName);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return getGeneratorObjectType(value, optionName);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const getDuplexType = (value, optionName) => {
|
|
67
|
-
validateNonGeneratorType(value, optionName, 'Duplex stream');
|
|
68
|
-
return 'duplex';
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const getTransformStreamType = (value, optionName) => {
|
|
72
|
-
validateNonGeneratorType(value, optionName, 'web TransformStream');
|
|
73
|
-
return 'webTransform';
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const validateNonGeneratorType = ({final, binary, objectMode}, optionName, typeName) => {
|
|
77
|
-
checkUndefinedOption(final, `${optionName}.final`, typeName);
|
|
78
|
-
checkUndefinedOption(binary, `${optionName}.binary`, typeName);
|
|
79
|
-
checkBooleanOption(objectMode, `${optionName}.objectMode`);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const checkUndefinedOption = (value, optionName, typeName) => {
|
|
83
|
-
if (value !== undefined) {
|
|
84
|
-
throw new TypeError(`The \`${optionName}\` option can only be defined when using a generator, not a ${typeName}.`);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const getGeneratorObjectType = ({transform, final, binary, objectMode}, optionName) => {
|
|
89
|
-
if (transform !== undefined && !isGenerator(transform)) {
|
|
90
|
-
throw new TypeError(`The \`${optionName}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (isDuplexStream(final, {checkOpen: false})) {
|
|
94
|
-
throw new TypeError(`The \`${optionName}.final\` option must not be a Duplex stream.`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (isTransformStream(final)) {
|
|
98
|
-
throw new TypeError(`The \`${optionName}.final\` option must not be a web TransformStream.`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (final !== undefined && !isGenerator(final)) {
|
|
102
|
-
throw new TypeError(`The \`${optionName}.final\` option must be a generator.`);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
checkBooleanOption(binary, `${optionName}.binary`);
|
|
106
|
-
checkBooleanOption(objectMode, `${optionName}.objectMode`);
|
|
107
|
-
|
|
108
|
-
return isAsyncGenerator(transform) || isAsyncGenerator(final) ? 'asyncGenerator' : 'generator';
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const checkBooleanOption = (value, optionName) => {
|
|
112
|
-
if (value !== undefined && typeof value !== 'boolean') {
|
|
113
|
-
throw new TypeError(`The \`${optionName}\` option must use a boolean.`);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const isGenerator = value => isAsyncGenerator(value) || isSyncGenerator(value);
|
|
118
|
-
export const isAsyncGenerator = value => Object.prototype.toString.call(value) === '[object AsyncGeneratorFunction]';
|
|
119
|
-
const isSyncGenerator = value => Object.prototype.toString.call(value) === '[object GeneratorFunction]';
|
|
120
|
-
const isTransformOptions = value => isPlainObj(value)
|
|
121
|
-
&& (value.transform !== undefined || value.final !== undefined);
|
|
122
|
-
|
|
123
|
-
export const isUrl = value => Object.prototype.toString.call(value) === '[object URL]';
|
|
124
|
-
export const isRegularUrl = value => isUrl(value) && value.protocol !== 'file:';
|
|
125
|
-
|
|
126
|
-
const isFilePathObject = value => isPlainObj(value)
|
|
127
|
-
&& Object.keys(value).length > 0
|
|
128
|
-
&& Object.keys(value).every(key => FILE_PATH_KEYS.has(key))
|
|
129
|
-
&& isFilePathString(value.file);
|
|
130
|
-
const FILE_PATH_KEYS = new Set(['file', 'append']);
|
|
131
|
-
export const isFilePathString = file => typeof file === 'string';
|
|
132
|
-
|
|
133
|
-
export const isUnknownStdioString = (type, value) => type === 'native'
|
|
134
|
-
&& typeof value === 'string'
|
|
135
|
-
&& !KNOWN_STDIO_STRINGS.has(value);
|
|
136
|
-
const KNOWN_STDIO_STRINGS = new Set(['ipc', 'ignore', 'inherit', 'overlapped', 'pipe']);
|
|
137
|
-
|
|
138
|
-
const isReadableStream = value => Object.prototype.toString.call(value) === '[object ReadableStream]';
|
|
139
|
-
export const isWritableStream = value => Object.prototype.toString.call(value) === '[object WritableStream]';
|
|
140
|
-
const isWebStream = value => isReadableStream(value) || isWritableStream(value);
|
|
141
|
-
const isTransformStream = value => isReadableStream(value?.readable) && isWritableStream(value?.writable);
|
|
142
|
-
|
|
143
|
-
const isAsyncIterableObject = value => isObject(value) && typeof value[Symbol.asyncIterator] === 'function';
|
|
144
|
-
const isIterableObject = value => isObject(value) && typeof value[Symbol.iterator] === 'function';
|
|
145
|
-
const isObject = value => typeof value === 'object' && value !== null;
|
|
146
|
-
|
|
147
|
-
// Types which modify `subprocess.std*`
|
|
148
|
-
export const TRANSFORM_TYPES = new Set(['generator', 'asyncGenerator', 'duplex', 'webTransform']);
|
|
149
|
-
// Types which write to a file or a file descriptor
|
|
150
|
-
export const FILE_TYPES = new Set(['fileUrl', 'filePath', 'fileNumber']);
|
|
151
|
-
// When two file descriptors of this type share the same target, we need to do some special logic
|
|
152
|
-
export const SPECIAL_DUPLICATE_TYPES_SYNC = new Set(['fileUrl', 'filePath']);
|
|
153
|
-
export const SPECIAL_DUPLICATE_TYPES = new Set([...SPECIAL_DUPLICATE_TYPES_SYNC, 'webStream', 'nodeStream']);
|
|
154
|
-
// Do not allow two file descriptors of this type sharing the same target
|
|
155
|
-
export const FORBID_DUPLICATE_TYPES = new Set(['webTransform', 'duplex']);
|
|
156
|
-
|
|
157
|
-
// Convert types to human-friendly strings for error messages
|
|
158
|
-
export const TYPE_TO_MESSAGE = {
|
|
159
|
-
generator: 'a generator',
|
|
160
|
-
asyncGenerator: 'an async generator',
|
|
161
|
-
fileUrl: 'a file URL',
|
|
162
|
-
filePath: 'a file path string',
|
|
163
|
-
fileNumber: 'a file descriptor number',
|
|
164
|
-
webStream: 'a web stream',
|
|
165
|
-
nodeStream: 'a Node.js stream',
|
|
166
|
-
webTransform: 'a web TransformStream',
|
|
167
|
-
duplex: 'a Duplex stream',
|
|
168
|
-
native: 'any value',
|
|
169
|
-
iterable: 'an iterable',
|
|
170
|
-
asyncIterable: 'an async iterable',
|
|
171
|
-
string: 'a string',
|
|
172
|
-
uint8Array: 'a Uint8Array',
|
|
173
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {onAbortedSignal} from '../utils/abort-signal.js';
|
|
2
|
-
|
|
3
|
-
// Validate the `cancelSignal` option
|
|
4
|
-
export const validateCancelSignal = ({cancelSignal}) => {
|
|
5
|
-
if (cancelSignal !== undefined && Object.prototype.toString.call(cancelSignal) !== '[object AbortSignal]') {
|
|
6
|
-
throw new Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(cancelSignal)}`);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// Terminate the subprocess when aborting the `cancelSignal` option and `gracefulSignal` is `false`
|
|
11
|
-
export const throwOnCancel = ({subprocess, cancelSignal, gracefulCancel, context, controller}) => cancelSignal === undefined || gracefulCancel
|
|
12
|
-
? []
|
|
13
|
-
: [terminateOnCancel(subprocess, cancelSignal, context, controller)];
|
|
14
|
-
|
|
15
|
-
const terminateOnCancel = async (subprocess, cancelSignal, context, {signal}) => {
|
|
16
|
-
await onAbortedSignal(cancelSignal, signal);
|
|
17
|
-
context.terminationReason ??= 'cancel';
|
|
18
|
-
subprocess.kill();
|
|
19
|
-
throw cancelSignal.reason;
|
|
20
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {addAbortListener} from 'node:events';
|
|
2
|
-
import {onExit} from 'signal-exit';
|
|
3
|
-
|
|
4
|
-
// If the `cleanup` option is used, call `subprocess.kill()` when the parent process exits
|
|
5
|
-
export const cleanupOnExit = (subprocess, {cleanup, detached}, {signal}) => {
|
|
6
|
-
if (!cleanup || detached) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const removeExitHandler = onExit(() => {
|
|
11
|
-
subprocess.kill();
|
|
12
|
-
});
|
|
13
|
-
addAbortListener(signal, () => {
|
|
14
|
-
removeExitHandler();
|
|
15
|
-
});
|
|
16
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {onAbortedSignal} from '../utils/abort-signal.js';
|
|
2
|
-
import {sendAbort} from '../ipc/graceful.js';
|
|
3
|
-
import {killOnTimeout} from './kill.js';
|
|
4
|
-
|
|
5
|
-
// Validate the `gracefulCancel` option
|
|
6
|
-
export const validateGracefulCancel = ({gracefulCancel, cancelSignal, ipc, serialization}) => {
|
|
7
|
-
if (!gracefulCancel) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (cancelSignal === undefined) {
|
|
12
|
-
throw new Error('The `cancelSignal` option must be defined when setting the `gracefulCancel` option.');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (!ipc) {
|
|
16
|
-
throw new Error('The `ipc` option cannot be false when setting the `gracefulCancel` option.');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (serialization === 'json') {
|
|
20
|
-
throw new Error('The `serialization` option cannot be \'json\' when setting the `gracefulCancel` option.');
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Send abort reason to the subprocess when aborting the `cancelSignal` option and `gracefulCancel` is `true`
|
|
25
|
-
export const throwOnGracefulCancel = ({
|
|
26
|
-
subprocess,
|
|
27
|
-
cancelSignal,
|
|
28
|
-
gracefulCancel,
|
|
29
|
-
forceKillAfterDelay,
|
|
30
|
-
context,
|
|
31
|
-
controller,
|
|
32
|
-
}) => gracefulCancel
|
|
33
|
-
? [sendOnAbort({
|
|
34
|
-
subprocess,
|
|
35
|
-
cancelSignal,
|
|
36
|
-
forceKillAfterDelay,
|
|
37
|
-
context,
|
|
38
|
-
controller,
|
|
39
|
-
})]
|
|
40
|
-
: [];
|
|
41
|
-
|
|
42
|
-
const sendOnAbort = async ({subprocess, cancelSignal, forceKillAfterDelay, context, controller: {signal}}) => {
|
|
43
|
-
await onAbortedSignal(cancelSignal, signal);
|
|
44
|
-
const reason = getReason(cancelSignal);
|
|
45
|
-
await sendAbort(subprocess, reason);
|
|
46
|
-
killOnTimeout({
|
|
47
|
-
kill: subprocess.kill,
|
|
48
|
-
forceKillAfterDelay,
|
|
49
|
-
context,
|
|
50
|
-
controllerSignal: signal,
|
|
51
|
-
});
|
|
52
|
-
context.terminationReason ??= 'gracefulCancel';
|
|
53
|
-
throw cancelSignal.reason;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// The default `reason` is a DOMException, which is not serializable with V8
|
|
57
|
-
// See https://github.com/nodejs/node/issues/53225
|
|
58
|
-
const getReason = ({reason}) => {
|
|
59
|
-
if (!(reason instanceof DOMException)) {
|
|
60
|
-
return reason;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const error = new Error(reason.message);
|
|
64
|
-
Object.defineProperty(error, 'stack', {
|
|
65
|
-
value: reason.stack,
|
|
66
|
-
enumerable: false,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
});
|
|
70
|
-
return error;
|
|
71
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {setTimeout} from 'node:timers/promises';
|
|
2
|
-
import {isErrorInstance} from '../return/final-error.js';
|
|
3
|
-
import {normalizeSignalArgument} from './signal.js';
|
|
4
|
-
|
|
5
|
-
// Normalize the `forceKillAfterDelay` option
|
|
6
|
-
export const normalizeForceKillAfterDelay = forceKillAfterDelay => {
|
|
7
|
-
if (forceKillAfterDelay === false) {
|
|
8
|
-
return forceKillAfterDelay;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (forceKillAfterDelay === true) {
|
|
12
|
-
return DEFAULT_FORCE_KILL_TIMEOUT;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (!Number.isFinite(forceKillAfterDelay) || forceKillAfterDelay < 0) {
|
|
16
|
-
throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${forceKillAfterDelay}\` (${typeof forceKillAfterDelay})`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return forceKillAfterDelay;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
|
|
23
|
-
|
|
24
|
-
// Monkey-patches `subprocess.kill()` to add `forceKillAfterDelay` behavior and `.kill(error)`
|
|
25
|
-
export const subprocessKill = (
|
|
26
|
-
{kill, options: {forceKillAfterDelay, killSignal}, onInternalError, context, controller},
|
|
27
|
-
signalOrError,
|
|
28
|
-
errorArgument,
|
|
29
|
-
) => {
|
|
30
|
-
const {signal, error} = parseKillArguments(signalOrError, errorArgument, killSignal);
|
|
31
|
-
emitKillError(error, onInternalError);
|
|
32
|
-
const killResult = kill(signal);
|
|
33
|
-
setKillTimeout({
|
|
34
|
-
kill,
|
|
35
|
-
signal,
|
|
36
|
-
forceKillAfterDelay,
|
|
37
|
-
killSignal,
|
|
38
|
-
killResult,
|
|
39
|
-
context,
|
|
40
|
-
controller,
|
|
41
|
-
});
|
|
42
|
-
return killResult;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const parseKillArguments = (signalOrError, errorArgument, killSignal) => {
|
|
46
|
-
const [signal = killSignal, error] = isErrorInstance(signalOrError)
|
|
47
|
-
? [undefined, signalOrError]
|
|
48
|
-
: [signalOrError, errorArgument];
|
|
49
|
-
|
|
50
|
-
if (typeof signal !== 'string' && !Number.isInteger(signal)) {
|
|
51
|
-
throw new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(signal)}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (error !== undefined && !isErrorInstance(error)) {
|
|
55
|
-
throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${error}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {signal: normalizeSignalArgument(signal), error};
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// Fails right away when calling `subprocess.kill(error)`.
|
|
62
|
-
// Does not wait for actual signal termination.
|
|
63
|
-
// Uses a deferred promise instead of the `error` event on the subprocess, as this is less intrusive.
|
|
64
|
-
const emitKillError = (error, onInternalError) => {
|
|
65
|
-
if (error !== undefined) {
|
|
66
|
-
onInternalError.reject(error);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const setKillTimeout = async ({kill, signal, forceKillAfterDelay, killSignal, killResult, context, controller}) => {
|
|
71
|
-
if (signal === killSignal && killResult) {
|
|
72
|
-
killOnTimeout({
|
|
73
|
-
kill,
|
|
74
|
-
forceKillAfterDelay,
|
|
75
|
-
context,
|
|
76
|
-
controllerSignal: controller.signal,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// Forcefully terminate a subprocess after a timeout
|
|
82
|
-
export const killOnTimeout = async ({kill, forceKillAfterDelay, context, controllerSignal}) => {
|
|
83
|
-
if (forceKillAfterDelay === false) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
await setTimeout(forceKillAfterDelay, undefined, {signal: controllerSignal});
|
|
89
|
-
if (kill('SIGKILL')) {
|
|
90
|
-
context.isForcefullyTerminated ??= true;
|
|
91
|
-
}
|
|
92
|
-
} catch {}
|
|
93
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {constants} from 'node:os';
|
|
2
|
-
import {signalsByName} from 'human-signals';
|
|
3
|
-
|
|
4
|
-
// Normalize signals for comparison purpose.
|
|
5
|
-
// Also validate the signal exists.
|
|
6
|
-
export const normalizeKillSignal = killSignal => {
|
|
7
|
-
const optionName = 'option `killSignal`';
|
|
8
|
-
if (killSignal === 0) {
|
|
9
|
-
throw new TypeError(`Invalid ${optionName}: 0 cannot be used.`);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return normalizeSignal(killSignal, optionName);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const normalizeSignalArgument = signal => signal === 0
|
|
16
|
-
? signal
|
|
17
|
-
: normalizeSignal(signal, '`subprocess.kill()`\'s argument');
|
|
18
|
-
|
|
19
|
-
const normalizeSignal = (signalNameOrInteger, optionName) => {
|
|
20
|
-
if (Number.isInteger(signalNameOrInteger)) {
|
|
21
|
-
return normalizeSignalInteger(signalNameOrInteger, optionName);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (typeof signalNameOrInteger === 'string') {
|
|
25
|
-
return normalizeSignalName(signalNameOrInteger, optionName);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
throw new TypeError(`Invalid ${optionName} ${String(signalNameOrInteger)}: it must be a string or an integer.\n${getAvailableSignals()}`);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const normalizeSignalInteger = (signalInteger, optionName) => {
|
|
32
|
-
if (signalsIntegerToName.has(signalInteger)) {
|
|
33
|
-
return signalsIntegerToName.get(signalInteger);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
throw new TypeError(`Invalid ${optionName} ${signalInteger}: this signal integer does not exist.\n${getAvailableSignals()}`);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getSignalsIntegerToName = () => new Map(Object.entries(constants.signals)
|
|
40
|
-
.reverse()
|
|
41
|
-
.map(([signalName, signalInteger]) => [signalInteger, signalName]));
|
|
42
|
-
|
|
43
|
-
const signalsIntegerToName = getSignalsIntegerToName();
|
|
44
|
-
|
|
45
|
-
const normalizeSignalName = (signalName, optionName) => {
|
|
46
|
-
if (signalName in constants.signals) {
|
|
47
|
-
return signalName;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (signalName.toUpperCase() in constants.signals) {
|
|
51
|
-
throw new TypeError(`Invalid ${optionName} '${signalName}': please rename it to '${signalName.toUpperCase()}'.`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
throw new TypeError(`Invalid ${optionName} '${signalName}': this signal name does not exist.\n${getAvailableSignals()}`);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const getAvailableSignals = () => `Available signal names: ${getAvailableSignalNames()}.
|
|
58
|
-
Available signal numbers: ${getAvailableSignalIntegers()}.`;
|
|
59
|
-
|
|
60
|
-
const getAvailableSignalNames = () => Object.keys(constants.signals)
|
|
61
|
-
.sort()
|
|
62
|
-
.map(signalName => `'${signalName}'`)
|
|
63
|
-
.join(', ');
|
|
64
|
-
|
|
65
|
-
const getAvailableSignalIntegers = () => [...new Set(Object.values(constants.signals)
|
|
66
|
-
.sort((signalInteger, signalIntegerTwo) => signalInteger - signalIntegerTwo))]
|
|
67
|
-
.join(', ');
|
|
68
|
-
|
|
69
|
-
// Human-friendly description of a signal
|
|
70
|
-
export const getSignalDescription = signal => signalsByName[signal].description;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {setTimeout} from 'node:timers/promises';
|
|
2
|
-
import {DiscardedError} from '../return/final-error.js';
|
|
3
|
-
|
|
4
|
-
// Validate `timeout` option
|
|
5
|
-
export const validateTimeout = ({timeout}) => {
|
|
6
|
-
if (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {
|
|
7
|
-
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// Fails when the `timeout` option is exceeded
|
|
12
|
-
export const throwOnTimeout = (subprocess, timeout, context, controller) => timeout === 0 || timeout === undefined
|
|
13
|
-
? []
|
|
14
|
-
: [killAfterTimeout(subprocess, timeout, context, controller)];
|
|
15
|
-
|
|
16
|
-
const killAfterTimeout = async (subprocess, timeout, context, {signal}) => {
|
|
17
|
-
await setTimeout(timeout, undefined, {signal});
|
|
18
|
-
context.terminationReason ??= 'timeout';
|
|
19
|
-
subprocess.kill();
|
|
20
|
-
throw new DiscardedError();
|
|
21
|
-
};
|