@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,111 +0,0 @@
|
|
|
1
|
-
import {debuglog} from 'node:util';
|
|
2
|
-
import isPlainObject from 'is-plain-obj';
|
|
3
|
-
import {STANDARD_STREAMS_ALIASES} from '../utils/standard-stream.js';
|
|
4
|
-
|
|
5
|
-
// Some options can have different values for `stdout`/`stderr`/`fd3`.
|
|
6
|
-
// This normalizes those to array of values.
|
|
7
|
-
// For example, `{verbose: {stdout: 'none', stderr: 'full'}}` becomes `{verbose: ['none', 'none', 'full']}`
|
|
8
|
-
export const normalizeFdSpecificOptions = options => {
|
|
9
|
-
const optionsCopy = {...options};
|
|
10
|
-
|
|
11
|
-
for (const optionName of FD_SPECIFIC_OPTIONS) {
|
|
12
|
-
optionsCopy[optionName] = normalizeFdSpecificOption(options, optionName);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return optionsCopy;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const normalizeFdSpecificOption = (options, optionName) => {
|
|
19
|
-
const optionBaseArray = Array.from({length: getStdioLength(options) + 1});
|
|
20
|
-
const optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);
|
|
21
|
-
return addDefaultValue(optionArray, optionName);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const getStdioLength = ({stdio}) => Array.isArray(stdio)
|
|
25
|
-
? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length)
|
|
26
|
-
: STANDARD_STREAMS_ALIASES.length;
|
|
27
|
-
|
|
28
|
-
const normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue)
|
|
29
|
-
? normalizeOptionObject(optionValue, optionArray, optionName)
|
|
30
|
-
: optionArray.fill(optionValue);
|
|
31
|
-
|
|
32
|
-
const normalizeOptionObject = (optionValue, optionArray, optionName) => {
|
|
33
|
-
for (const fdName of Object.keys(optionValue).sort(compareFdName)) {
|
|
34
|
-
for (const fdNumber of parseFdName(fdName, optionName, optionArray)) {
|
|
35
|
-
optionArray[fdNumber] = optionValue[fdName];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return optionArray;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// Ensure priority order when setting both `stdout`/`stderr`, `fd1`/`fd2`, and `all`
|
|
43
|
-
const compareFdName = (fdNameA, fdNameB) => getFdNameOrder(fdNameA) < getFdNameOrder(fdNameB) ? 1 : -1;
|
|
44
|
-
|
|
45
|
-
const getFdNameOrder = fdName => {
|
|
46
|
-
if (fdName === 'stdout' || fdName === 'stderr') {
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return fdName === 'all' ? 2 : 1;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const parseFdName = (fdName, optionName, optionArray) => {
|
|
54
|
-
if (fdName === 'ipc') {
|
|
55
|
-
return [optionArray.length - 1];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const fdNumber = parseFd(fdName);
|
|
59
|
-
if (fdNumber === undefined || fdNumber === 0) {
|
|
60
|
-
throw new TypeError(`"${optionName}.${fdName}" is invalid.
|
|
61
|
-
It must be "${optionName}.stdout", "${optionName}.stderr", "${optionName}.all", "${optionName}.ipc", or "${optionName}.fd3", "${optionName}.fd4" (and so on).`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (fdNumber >= optionArray.length) {
|
|
65
|
-
throw new TypeError(`"${optionName}.${fdName}" is invalid: that file descriptor does not exist.
|
|
66
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return fdNumber === 'all' ? [1, 2] : [fdNumber];
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Use the same syntax for fd-specific options and the `from`/`to` options
|
|
73
|
-
export const parseFd = fdName => {
|
|
74
|
-
if (fdName === 'all') {
|
|
75
|
-
return fdName;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (STANDARD_STREAMS_ALIASES.includes(fdName)) {
|
|
79
|
-
return STANDARD_STREAMS_ALIASES.indexOf(fdName);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const regexpResult = FD_REGEXP.exec(fdName);
|
|
83
|
-
if (regexpResult !== null) {
|
|
84
|
-
return Number(regexpResult[1]);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const FD_REGEXP = /^fd(\d+)$/;
|
|
89
|
-
|
|
90
|
-
const addDefaultValue = (optionArray, optionName) => optionArray.map(optionValue => optionValue === undefined
|
|
91
|
-
? DEFAULT_OPTIONS[optionName]
|
|
92
|
-
: optionValue);
|
|
93
|
-
|
|
94
|
-
// Default value for the `verbose` option
|
|
95
|
-
const verboseDefault = debuglog('execa').enabled ? 'full' : 'none';
|
|
96
|
-
|
|
97
|
-
const DEFAULT_OPTIONS = {
|
|
98
|
-
lines: false,
|
|
99
|
-
buffer: true,
|
|
100
|
-
maxBuffer: 1000 * 1000 * 100,
|
|
101
|
-
verbose: verboseDefault,
|
|
102
|
-
stripFinalNewline: true,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// List of options which can have different values for `stdout`/`stderr`
|
|
106
|
-
export const FD_SPECIFIC_OPTIONS = ['lines', 'buffer', 'maxBuffer', 'verbose', 'stripFinalNewline'];
|
|
107
|
-
|
|
108
|
-
// Retrieve fd-specific option
|
|
109
|
-
export const getFdSpecificValue = (optionArray, fdNumber) => fdNumber === 'ipc'
|
|
110
|
-
? optionArray.at(-1)
|
|
111
|
-
: optionArray[fdNumber];
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {initializeConcurrentStreams} from './concurrent.js';
|
|
2
|
-
import {createReadable} from './readable.js';
|
|
3
|
-
import {createWritable} from './writable.js';
|
|
4
|
-
import {createDuplex} from './duplex.js';
|
|
5
|
-
import {createIterable} from './iterable.js';
|
|
6
|
-
|
|
7
|
-
// Add methods to convert the subprocess to a stream or iterable
|
|
8
|
-
export const addConvertedStreams = (subprocess, {encoding}) => {
|
|
9
|
-
const concurrentStreams = initializeConcurrentStreams();
|
|
10
|
-
subprocess.readable = createReadable.bind(undefined, {subprocess, concurrentStreams, encoding});
|
|
11
|
-
subprocess.writable = createWritable.bind(undefined, {subprocess, concurrentStreams});
|
|
12
|
-
subprocess.duplex = createDuplex.bind(undefined, {subprocess, concurrentStreams, encoding});
|
|
13
|
-
subprocess.iterable = createIterable.bind(undefined, subprocess, encoding);
|
|
14
|
-
subprocess[Symbol.asyncIterator] = createIterable.bind(undefined, subprocess, encoding, {});
|
|
15
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import {createDeferred} from '../utils/deferred.js';
|
|
2
|
-
|
|
3
|
-
// When using multiple `.readable()`/`.writable()`/`.duplex()`, `final` and `destroy` should wait for other streams
|
|
4
|
-
export const initializeConcurrentStreams = () => ({
|
|
5
|
-
readableDestroy: new WeakMap(),
|
|
6
|
-
writableFinal: new WeakMap(),
|
|
7
|
-
writableDestroy: new WeakMap(),
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// Each file descriptor + `waitName` has its own array of promises.
|
|
11
|
-
// Each promise is a single `.readable()`/`.writable()`/`.duplex()` call.
|
|
12
|
-
export const addConcurrentStream = (concurrentStreams, stream, waitName) => {
|
|
13
|
-
const weakMap = concurrentStreams[waitName];
|
|
14
|
-
if (!weakMap.has(stream)) {
|
|
15
|
-
weakMap.set(stream, []);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const promises = weakMap.get(stream);
|
|
19
|
-
const promise = createDeferred();
|
|
20
|
-
promises.push(promise);
|
|
21
|
-
const resolve = promise.resolve.bind(promise);
|
|
22
|
-
return {resolve, promises};
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// Wait for other streams, but stop waiting when subprocess ends
|
|
26
|
-
export const waitForConcurrentStreams = async ({resolve, promises}, subprocess) => {
|
|
27
|
-
resolve();
|
|
28
|
-
const [isSubprocessExit] = await Promise.race([
|
|
29
|
-
Promise.allSettled([true, subprocess]),
|
|
30
|
-
Promise.all([false, ...promises]),
|
|
31
|
-
]);
|
|
32
|
-
return !isSubprocessExit;
|
|
33
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {Duplex} from 'node:stream';
|
|
2
|
-
import {callbackify} from 'node:util';
|
|
3
|
-
import {BINARY_ENCODINGS} from '../arguments/encoding-option.js';
|
|
4
|
-
import {
|
|
5
|
-
getSubprocessStdout,
|
|
6
|
-
getReadableOptions,
|
|
7
|
-
getReadableMethods,
|
|
8
|
-
onStdoutFinished,
|
|
9
|
-
onReadableDestroy,
|
|
10
|
-
} from './readable.js';
|
|
11
|
-
import {
|
|
12
|
-
getSubprocessStdin,
|
|
13
|
-
getWritableMethods,
|
|
14
|
-
onStdinFinished,
|
|
15
|
-
onWritableDestroy,
|
|
16
|
-
} from './writable.js';
|
|
17
|
-
|
|
18
|
-
// Create a `Duplex` stream combining both `subprocess.readable()` and `subprocess.writable()`
|
|
19
|
-
export const createDuplex = ({subprocess, concurrentStreams, encoding}, {from, to, binary: binaryOption = true, preserveNewlines = true} = {}) => {
|
|
20
|
-
const binary = binaryOption || BINARY_ENCODINGS.has(encoding);
|
|
21
|
-
const {subprocessStdout, waitReadableDestroy} = getSubprocessStdout(subprocess, from, concurrentStreams);
|
|
22
|
-
const {subprocessStdin, waitWritableFinal, waitWritableDestroy} = getSubprocessStdin(subprocess, to, concurrentStreams);
|
|
23
|
-
const {readableEncoding, readableObjectMode, readableHighWaterMark} = getReadableOptions(subprocessStdout, binary);
|
|
24
|
-
const {read, onStdoutDataDone} = getReadableMethods({
|
|
25
|
-
subprocessStdout,
|
|
26
|
-
subprocess,
|
|
27
|
-
binary,
|
|
28
|
-
encoding,
|
|
29
|
-
preserveNewlines,
|
|
30
|
-
});
|
|
31
|
-
const duplex = new Duplex({
|
|
32
|
-
read,
|
|
33
|
-
...getWritableMethods(subprocessStdin, subprocess, waitWritableFinal),
|
|
34
|
-
destroy: callbackify(onDuplexDestroy.bind(undefined, {
|
|
35
|
-
subprocessStdout,
|
|
36
|
-
subprocessStdin,
|
|
37
|
-
subprocess,
|
|
38
|
-
waitReadableDestroy,
|
|
39
|
-
waitWritableFinal,
|
|
40
|
-
waitWritableDestroy,
|
|
41
|
-
})),
|
|
42
|
-
readableHighWaterMark,
|
|
43
|
-
writableHighWaterMark: subprocessStdin.writableHighWaterMark,
|
|
44
|
-
readableObjectMode,
|
|
45
|
-
writableObjectMode: subprocessStdin.writableObjectMode,
|
|
46
|
-
encoding: readableEncoding,
|
|
47
|
-
});
|
|
48
|
-
onStdoutFinished({
|
|
49
|
-
subprocessStdout,
|
|
50
|
-
onStdoutDataDone,
|
|
51
|
-
readable: duplex,
|
|
52
|
-
subprocess,
|
|
53
|
-
subprocessStdin,
|
|
54
|
-
});
|
|
55
|
-
onStdinFinished(subprocessStdin, duplex, subprocessStdout);
|
|
56
|
-
return duplex;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const onDuplexDestroy = async ({subprocessStdout, subprocessStdin, subprocess, waitReadableDestroy, waitWritableFinal, waitWritableDestroy}, error) => {
|
|
60
|
-
await Promise.all([
|
|
61
|
-
onReadableDestroy({subprocessStdout, subprocess, waitReadableDestroy}, error),
|
|
62
|
-
onWritableDestroy({
|
|
63
|
-
subprocessStdin,
|
|
64
|
-
subprocess,
|
|
65
|
-
waitWritableFinal,
|
|
66
|
-
waitWritableDestroy,
|
|
67
|
-
}, error),
|
|
68
|
-
]);
|
|
69
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {BINARY_ENCODINGS} from '../arguments/encoding-option.js';
|
|
2
|
-
import {getFromStream} from '../arguments/fd-options.js';
|
|
3
|
-
import {iterateOnSubprocessStream} from '../io/iterate.js';
|
|
4
|
-
|
|
5
|
-
// Convert the subprocess to an async iterable
|
|
6
|
-
export const createIterable = (subprocess, encoding, {
|
|
7
|
-
from,
|
|
8
|
-
binary: binaryOption = false,
|
|
9
|
-
preserveNewlines = false,
|
|
10
|
-
} = {}) => {
|
|
11
|
-
const binary = binaryOption || BINARY_ENCODINGS.has(encoding);
|
|
12
|
-
const subprocessStdout = getFromStream(subprocess, from);
|
|
13
|
-
const onStdoutData = iterateOnSubprocessStream({
|
|
14
|
-
subprocessStdout,
|
|
15
|
-
subprocess,
|
|
16
|
-
binary,
|
|
17
|
-
shouldEncode: true,
|
|
18
|
-
encoding,
|
|
19
|
-
preserveNewlines,
|
|
20
|
-
});
|
|
21
|
-
return iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const iterateOnStdoutData = async function * (onStdoutData, subprocessStdout, subprocess) {
|
|
25
|
-
try {
|
|
26
|
-
yield * onStdoutData;
|
|
27
|
-
} finally {
|
|
28
|
-
if (subprocessStdout.readable) {
|
|
29
|
-
subprocessStdout.destroy();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await subprocess;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import {Readable} from 'node:stream';
|
|
2
|
-
import {callbackify} from 'node:util';
|
|
3
|
-
import {BINARY_ENCODINGS} from '../arguments/encoding-option.js';
|
|
4
|
-
import {getFromStream} from '../arguments/fd-options.js';
|
|
5
|
-
import {iterateOnSubprocessStream, DEFAULT_OBJECT_HIGH_WATER_MARK} from '../io/iterate.js';
|
|
6
|
-
import {createDeferred} from '../utils/deferred.js';
|
|
7
|
-
import {addConcurrentStream, waitForConcurrentStreams} from './concurrent.js';
|
|
8
|
-
import {
|
|
9
|
-
safeWaitForSubprocessStdin,
|
|
10
|
-
waitForSubprocessStdout,
|
|
11
|
-
waitForSubprocess,
|
|
12
|
-
destroyOtherStream,
|
|
13
|
-
} from './shared.js';
|
|
14
|
-
|
|
15
|
-
// Create a `Readable` stream that forwards from `stdout` and awaits the subprocess
|
|
16
|
-
export const createReadable = ({subprocess, concurrentStreams, encoding}, {from, binary: binaryOption = true, preserveNewlines = true} = {}) => {
|
|
17
|
-
const binary = binaryOption || BINARY_ENCODINGS.has(encoding);
|
|
18
|
-
const {subprocessStdout, waitReadableDestroy} = getSubprocessStdout(subprocess, from, concurrentStreams);
|
|
19
|
-
const {readableEncoding, readableObjectMode, readableHighWaterMark} = getReadableOptions(subprocessStdout, binary);
|
|
20
|
-
const {read, onStdoutDataDone} = getReadableMethods({
|
|
21
|
-
subprocessStdout,
|
|
22
|
-
subprocess,
|
|
23
|
-
binary,
|
|
24
|
-
encoding,
|
|
25
|
-
preserveNewlines,
|
|
26
|
-
});
|
|
27
|
-
const readable = new Readable({
|
|
28
|
-
read,
|
|
29
|
-
destroy: callbackify(onReadableDestroy.bind(undefined, {subprocessStdout, subprocess, waitReadableDestroy})),
|
|
30
|
-
highWaterMark: readableHighWaterMark,
|
|
31
|
-
objectMode: readableObjectMode,
|
|
32
|
-
encoding: readableEncoding,
|
|
33
|
-
});
|
|
34
|
-
onStdoutFinished({
|
|
35
|
-
subprocessStdout,
|
|
36
|
-
onStdoutDataDone,
|
|
37
|
-
readable,
|
|
38
|
-
subprocess,
|
|
39
|
-
});
|
|
40
|
-
return readable;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Retrieve `stdout` (or other stream depending on `from`)
|
|
44
|
-
export const getSubprocessStdout = (subprocess, from, concurrentStreams) => {
|
|
45
|
-
const subprocessStdout = getFromStream(subprocess, from);
|
|
46
|
-
const waitReadableDestroy = addConcurrentStream(concurrentStreams, subprocessStdout, 'readableDestroy');
|
|
47
|
-
return {subprocessStdout, waitReadableDestroy};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const getReadableOptions = ({readableEncoding, readableObjectMode, readableHighWaterMark}, binary) => binary
|
|
51
|
-
? {readableEncoding, readableObjectMode, readableHighWaterMark}
|
|
52
|
-
: {readableEncoding, readableObjectMode: true, readableHighWaterMark: DEFAULT_OBJECT_HIGH_WATER_MARK};
|
|
53
|
-
|
|
54
|
-
export const getReadableMethods = ({subprocessStdout, subprocess, binary, encoding, preserveNewlines}) => {
|
|
55
|
-
const onStdoutDataDone = createDeferred();
|
|
56
|
-
const onStdoutData = iterateOnSubprocessStream({
|
|
57
|
-
subprocessStdout,
|
|
58
|
-
subprocess,
|
|
59
|
-
binary,
|
|
60
|
-
shouldEncode: !binary,
|
|
61
|
-
encoding,
|
|
62
|
-
preserveNewlines,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
read() {
|
|
67
|
-
onRead(this, onStdoutData, onStdoutDataDone);
|
|
68
|
-
},
|
|
69
|
-
onStdoutDataDone,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// Forwards data from `stdout` to `readable`
|
|
74
|
-
const onRead = async (readable, onStdoutData, onStdoutDataDone) => {
|
|
75
|
-
try {
|
|
76
|
-
const {value, done} = await onStdoutData.next();
|
|
77
|
-
if (done) {
|
|
78
|
-
onStdoutDataDone.resolve();
|
|
79
|
-
} else {
|
|
80
|
-
readable.push(value);
|
|
81
|
-
}
|
|
82
|
-
} catch {}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// When `subprocess.stdout` ends/aborts/errors, do the same on `readable`.
|
|
86
|
-
// Await the subprocess, for the same reason as above.
|
|
87
|
-
export const onStdoutFinished = async ({subprocessStdout, onStdoutDataDone, readable, subprocess, subprocessStdin}) => {
|
|
88
|
-
try {
|
|
89
|
-
await waitForSubprocessStdout(subprocessStdout);
|
|
90
|
-
await subprocess;
|
|
91
|
-
await safeWaitForSubprocessStdin(subprocessStdin);
|
|
92
|
-
await onStdoutDataDone;
|
|
93
|
-
|
|
94
|
-
if (readable.readable) {
|
|
95
|
-
readable.push(null);
|
|
96
|
-
}
|
|
97
|
-
} catch (error) {
|
|
98
|
-
await safeWaitForSubprocessStdin(subprocessStdin);
|
|
99
|
-
destroyOtherReadable(readable, error);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// When `readable` aborts/errors, do the same on `subprocess.stdout`
|
|
104
|
-
export const onReadableDestroy = async ({subprocessStdout, subprocess, waitReadableDestroy}, error) => {
|
|
105
|
-
if (await waitForConcurrentStreams(waitReadableDestroy, subprocess)) {
|
|
106
|
-
destroyOtherReadable(subprocessStdout, error);
|
|
107
|
-
await waitForSubprocess(subprocess, error);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const destroyOtherReadable = (stream, error) => {
|
|
112
|
-
destroyOtherStream(stream, stream.readable, error);
|
|
113
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {finished} from 'node:stream/promises';
|
|
2
|
-
import {isStreamAbort} from '../resolve/wait-stream.js';
|
|
3
|
-
|
|
4
|
-
export const safeWaitForSubprocessStdin = async subprocessStdin => {
|
|
5
|
-
if (subprocessStdin === undefined) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
await waitForSubprocessStdin(subprocessStdin);
|
|
11
|
-
} catch {}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const safeWaitForSubprocessStdout = async subprocessStdout => {
|
|
15
|
-
if (subprocessStdout === undefined) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
await waitForSubprocessStdout(subprocessStdout);
|
|
21
|
-
} catch {}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const waitForSubprocessStdin = async subprocessStdin => {
|
|
25
|
-
await finished(subprocessStdin, {cleanup: true, readable: false, writable: true});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const waitForSubprocessStdout = async subprocessStdout => {
|
|
29
|
-
await finished(subprocessStdout, {cleanup: true, readable: true, writable: false});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// When `readable` or `writable` aborts/errors, awaits the subprocess, for the reason mentioned above
|
|
33
|
-
export const waitForSubprocess = async (subprocess, error) => {
|
|
34
|
-
await subprocess;
|
|
35
|
-
if (error) {
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const destroyOtherStream = (stream, isOpen, error) => {
|
|
41
|
-
if (error && !isStreamAbort(error)) {
|
|
42
|
-
stream.destroy(error);
|
|
43
|
-
} else if (isOpen) {
|
|
44
|
-
stream.destroy();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {Writable} from 'node:stream';
|
|
2
|
-
import {callbackify} from 'node:util';
|
|
3
|
-
import {getToStream} from '../arguments/fd-options.js';
|
|
4
|
-
import {addConcurrentStream, waitForConcurrentStreams} from './concurrent.js';
|
|
5
|
-
import {
|
|
6
|
-
safeWaitForSubprocessStdout,
|
|
7
|
-
waitForSubprocessStdin,
|
|
8
|
-
waitForSubprocess,
|
|
9
|
-
destroyOtherStream,
|
|
10
|
-
} from './shared.js';
|
|
11
|
-
|
|
12
|
-
// Create a `Writable` stream that forwards to `stdin` and awaits the subprocess
|
|
13
|
-
export const createWritable = ({subprocess, concurrentStreams}, {to} = {}) => {
|
|
14
|
-
const {subprocessStdin, waitWritableFinal, waitWritableDestroy} = getSubprocessStdin(subprocess, to, concurrentStreams);
|
|
15
|
-
const writable = new Writable({
|
|
16
|
-
...getWritableMethods(subprocessStdin, subprocess, waitWritableFinal),
|
|
17
|
-
destroy: callbackify(onWritableDestroy.bind(undefined, {
|
|
18
|
-
subprocessStdin,
|
|
19
|
-
subprocess,
|
|
20
|
-
waitWritableFinal,
|
|
21
|
-
waitWritableDestroy,
|
|
22
|
-
})),
|
|
23
|
-
highWaterMark: subprocessStdin.writableHighWaterMark,
|
|
24
|
-
objectMode: subprocessStdin.writableObjectMode,
|
|
25
|
-
});
|
|
26
|
-
onStdinFinished(subprocessStdin, writable);
|
|
27
|
-
return writable;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Retrieve `stdin` (or other stream depending on `to`)
|
|
31
|
-
export const getSubprocessStdin = (subprocess, to, concurrentStreams) => {
|
|
32
|
-
const subprocessStdin = getToStream(subprocess, to);
|
|
33
|
-
const waitWritableFinal = addConcurrentStream(concurrentStreams, subprocessStdin, 'writableFinal');
|
|
34
|
-
const waitWritableDestroy = addConcurrentStream(concurrentStreams, subprocessStdin, 'writableDestroy');
|
|
35
|
-
return {subprocessStdin, waitWritableFinal, waitWritableDestroy};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const getWritableMethods = (subprocessStdin, subprocess, waitWritableFinal) => ({
|
|
39
|
-
write: onWrite.bind(undefined, subprocessStdin),
|
|
40
|
-
final: callbackify(onWritableFinal.bind(undefined, subprocessStdin, subprocess, waitWritableFinal)),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Forwards data from `writable` to `stdin`
|
|
44
|
-
const onWrite = (subprocessStdin, chunk, encoding, done) => {
|
|
45
|
-
if (subprocessStdin.write(chunk, encoding)) {
|
|
46
|
-
done();
|
|
47
|
-
} else {
|
|
48
|
-
subprocessStdin.once('drain', done);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Ensures that the writable `final` and readable `end` events awaits the subprocess.
|
|
53
|
-
// Like this, any subprocess failure is propagated as a stream `error` event, instead of being lost.
|
|
54
|
-
// The user does not need to `await` the subprocess anymore, but now needs to await the stream completion or error.
|
|
55
|
-
// When multiple writables are targeting the same stream, they wait for each other, unless the subprocess ends first.
|
|
56
|
-
const onWritableFinal = async (subprocessStdin, subprocess, waitWritableFinal) => {
|
|
57
|
-
if (await waitForConcurrentStreams(waitWritableFinal, subprocess)) {
|
|
58
|
-
if (subprocessStdin.writable) {
|
|
59
|
-
subprocessStdin.end();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
await subprocess;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// When `subprocess.stdin` ends/aborts/errors, do the same on `writable`.
|
|
67
|
-
export const onStdinFinished = async (subprocessStdin, writable, subprocessStdout) => {
|
|
68
|
-
try {
|
|
69
|
-
await waitForSubprocessStdin(subprocessStdin);
|
|
70
|
-
if (writable.writable) {
|
|
71
|
-
writable.end();
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
await safeWaitForSubprocessStdout(subprocessStdout);
|
|
75
|
-
destroyOtherWritable(writable, error);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// When `writable` aborts/errors, do the same on `subprocess.stdin`
|
|
80
|
-
export const onWritableDestroy = async ({subprocessStdin, subprocess, waitWritableFinal, waitWritableDestroy}, error) => {
|
|
81
|
-
await waitForConcurrentStreams(waitWritableFinal, subprocess);
|
|
82
|
-
if (await waitForConcurrentStreams(waitWritableDestroy, subprocess)) {
|
|
83
|
-
destroyOtherWritable(subprocessStdin, error);
|
|
84
|
-
await waitForSubprocess(subprocess, error);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const destroyOtherWritable = (stream, error) => {
|
|
89
|
-
destroyOtherStream(stream, stream.writable, error);
|
|
90
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {setImmediate} from 'node:timers/promises';
|
|
2
|
-
import getStream, {getStreamAsArrayBuffer, getStreamAsArray} from 'get-stream';
|
|
3
|
-
import {isArrayBuffer} from '../utils/uint-array.js';
|
|
4
|
-
import {shouldLogOutput, logLines} from '../verbose/output.js';
|
|
5
|
-
import {iterateForResult} from './iterate.js';
|
|
6
|
-
import {handleMaxBuffer} from './max-buffer.js';
|
|
7
|
-
import {getStripFinalNewline} from './strip-newline.js';
|
|
8
|
-
|
|
9
|
-
// Retrieve `result.stdout|stderr|all|stdio[*]`
|
|
10
|
-
export const getStreamOutput = async ({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, verboseInfo, streamInfo}) => {
|
|
11
|
-
const logPromise = logOutputAsync({
|
|
12
|
-
stream,
|
|
13
|
-
onStreamEnd,
|
|
14
|
-
fdNumber,
|
|
15
|
-
encoding,
|
|
16
|
-
allMixed,
|
|
17
|
-
verboseInfo,
|
|
18
|
-
streamInfo,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
if (!buffer) {
|
|
22
|
-
await Promise.all([resumeStream(stream), logPromise]);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const stripFinalNewlineValue = getStripFinalNewline(stripFinalNewline, fdNumber);
|
|
27
|
-
const iterable = iterateForResult({
|
|
28
|
-
stream,
|
|
29
|
-
onStreamEnd,
|
|
30
|
-
lines,
|
|
31
|
-
encoding,
|
|
32
|
-
stripFinalNewline: stripFinalNewlineValue,
|
|
33
|
-
allMixed,
|
|
34
|
-
});
|
|
35
|
-
const [output] = await Promise.all([
|
|
36
|
-
getStreamContents({
|
|
37
|
-
stream,
|
|
38
|
-
iterable,
|
|
39
|
-
fdNumber,
|
|
40
|
-
encoding,
|
|
41
|
-
maxBuffer,
|
|
42
|
-
lines,
|
|
43
|
-
}),
|
|
44
|
-
logPromise,
|
|
45
|
-
]);
|
|
46
|
-
return output;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const logOutputAsync = async ({stream, onStreamEnd, fdNumber, encoding, allMixed, verboseInfo, streamInfo: {fileDescriptors}}) => {
|
|
50
|
-
if (!shouldLogOutput({
|
|
51
|
-
stdioItems: fileDescriptors[fdNumber]?.stdioItems,
|
|
52
|
-
encoding,
|
|
53
|
-
verboseInfo,
|
|
54
|
-
fdNumber,
|
|
55
|
-
})) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const linesIterable = iterateForResult({
|
|
60
|
-
stream,
|
|
61
|
-
onStreamEnd,
|
|
62
|
-
lines: true,
|
|
63
|
-
encoding,
|
|
64
|
-
stripFinalNewline: true,
|
|
65
|
-
allMixed,
|
|
66
|
-
});
|
|
67
|
-
await logLines(linesIterable, stream, fdNumber, verboseInfo);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// When using `buffer: false`, users need to read `subprocess.stdout|stderr|all` right away
|
|
71
|
-
// See https://github.com/sindresorhus/execa/issues/730 and https://github.com/sindresorhus/execa/pull/729#discussion_r1465496310
|
|
72
|
-
const resumeStream = async stream => {
|
|
73
|
-
await setImmediate();
|
|
74
|
-
if (stream.readableFlowing === null) {
|
|
75
|
-
stream.resume();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const getStreamContents = async ({stream, stream: {readableObjectMode}, iterable, fdNumber, encoding, maxBuffer, lines}) => {
|
|
80
|
-
try {
|
|
81
|
-
if (readableObjectMode || lines) {
|
|
82
|
-
return await getStreamAsArray(iterable, {maxBuffer});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (encoding === 'buffer') {
|
|
86
|
-
return new Uint8Array(await getStreamAsArrayBuffer(iterable, {maxBuffer}));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return await getStream(iterable, {maxBuffer});
|
|
90
|
-
} catch (error) {
|
|
91
|
-
return handleBufferedData(handleMaxBuffer({
|
|
92
|
-
error,
|
|
93
|
-
stream,
|
|
94
|
-
readableObjectMode,
|
|
95
|
-
lines,
|
|
96
|
-
encoding,
|
|
97
|
-
fdNumber,
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// On failure, `result.stdout|stderr|all` should contain the currently buffered stream
|
|
103
|
-
// They are automatically closed and flushed by Node.js when the subprocess exits
|
|
104
|
-
// When `buffer` is `false`, `streamPromise` is `undefined` and there is no buffered data to retrieve
|
|
105
|
-
export const getBufferedData = async streamPromise => {
|
|
106
|
-
try {
|
|
107
|
-
return await streamPromise;
|
|
108
|
-
} catch (error) {
|
|
109
|
-
return handleBufferedData(error);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// Ensure we are returning Uint8Arrays when using `encoding: 'buffer'`
|
|
114
|
-
const handleBufferedData = ({bufferedData}) => isArrayBuffer(bufferedData)
|
|
115
|
-
? new Uint8Array(bufferedData)
|
|
116
|
-
: bufferedData;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {runGeneratorsSync} from '../transform/generator.js';
|
|
2
|
-
import {joinToUint8Array, isUint8Array} from '../utils/uint-array.js';
|
|
3
|
-
import {TYPE_TO_MESSAGE} from '../stdio/type.js';
|
|
4
|
-
|
|
5
|
-
// Apply `stdin`/`input`/`inputFile` options, before spawning, in sync mode, by converting it to the `input` option
|
|
6
|
-
export const addInputOptionsSync = (fileDescriptors, options) => {
|
|
7
|
-
for (const fdNumber of getInputFdNumbers(fileDescriptors)) {
|
|
8
|
-
addInputOptionSync(fileDescriptors, fdNumber, options);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const getInputFdNumbers = fileDescriptors => new Set(Object.entries(fileDescriptors)
|
|
13
|
-
.filter(([, {direction}]) => direction === 'input')
|
|
14
|
-
.map(([fdNumber]) => Number(fdNumber)));
|
|
15
|
-
|
|
16
|
-
const addInputOptionSync = (fileDescriptors, fdNumber, options) => {
|
|
17
|
-
const {stdioItems} = fileDescriptors[fdNumber];
|
|
18
|
-
const allStdioItems = stdioItems.filter(({contents}) => contents !== undefined);
|
|
19
|
-
if (allStdioItems.length === 0) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (fdNumber !== 0) {
|
|
24
|
-
const [{type, optionName}] = allStdioItems;
|
|
25
|
-
throw new TypeError(`Only the \`stdin\` option, not \`${optionName}\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const allContents = allStdioItems.map(({contents}) => contents);
|
|
29
|
-
const transformedContents = allContents.map(contents => applySingleInputGeneratorsSync(contents, stdioItems));
|
|
30
|
-
options.input = joinToUint8Array(transformedContents);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const applySingleInputGeneratorsSync = (contents, stdioItems) => {
|
|
34
|
-
const newContents = runGeneratorsSync(contents, stdioItems, 'utf8', true);
|
|
35
|
-
validateSerializable(newContents);
|
|
36
|
-
return joinToUint8Array(newContents);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const validateSerializable = newContents => {
|
|
40
|
-
const invalidItem = newContents.find(item => typeof item !== 'string' && !isUint8Array(item));
|
|
41
|
-
if (invalidItem !== undefined) {
|
|
42
|
-
throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${invalidItem}.`);
|
|
43
|
-
}
|
|
44
|
-
};
|