@kubb/agent 4.28.1 → 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 +378 -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
|
-
// Validate the IPC channel is connected before receiving/sending messages
|
|
2
|
-
export const validateIpcMethod = ({methodName, isSubprocess, ipc, isConnected}) => {
|
|
3
|
-
validateIpcOption(methodName, isSubprocess, ipc);
|
|
4
|
-
validateConnection(methodName, isSubprocess, isConnected);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// Better error message when forgetting to set `ipc: true` and using the IPC methods
|
|
8
|
-
const validateIpcOption = (methodName, isSubprocess, ipc) => {
|
|
9
|
-
if (!ipc) {
|
|
10
|
-
throw new Error(`${getMethodName(methodName, isSubprocess)} can only be used if the \`ipc\` option is \`true\`.`);
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Better error message when one process does not send/receive messages once the other process has disconnected.
|
|
15
|
-
// This also makes it clear that any buffered messages are lost once either process has disconnected.
|
|
16
|
-
// Also when aborting `cancelSignal` after disconnecting the IPC.
|
|
17
|
-
export const validateConnection = (methodName, isSubprocess, isConnected) => {
|
|
18
|
-
if (!isConnected) {
|
|
19
|
-
throw new Error(`${getMethodName(methodName, isSubprocess)} cannot be used: the ${getOtherProcessName(isSubprocess)} has already exited or disconnected.`);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// When `getOneMessage()` could not complete due to an early disconnection
|
|
24
|
-
export const throwOnEarlyDisconnect = isSubprocess => {
|
|
25
|
-
throw new Error(`${getMethodName('getOneMessage', isSubprocess)} could not complete: the ${getOtherProcessName(isSubprocess)} exited or disconnected.`);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// When both processes use `sendMessage()` with `strict` at the same time
|
|
29
|
-
export const throwOnStrictDeadlockError = isSubprocess => {
|
|
30
|
-
throw new Error(`${getMethodName('sendMessage', isSubprocess)} failed: the ${getOtherProcessName(isSubprocess)} is sending a message too, instead of listening to incoming messages.
|
|
31
|
-
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
32
|
-
|
|
33
|
-
const [receivedMessage] = await Promise.all([
|
|
34
|
-
${getMethodName('getOneMessage', isSubprocess)},
|
|
35
|
-
${getMethodName('sendMessage', isSubprocess, 'message, {strict: true}')},
|
|
36
|
-
]);`);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// When the other process used `strict` but the current process had I/O error calling `sendMessage()` for the response
|
|
40
|
-
export const getStrictResponseError = (error, isSubprocess) => new Error(`${getMethodName('sendMessage', isSubprocess)} failed when sending an acknowledgment response to the ${getOtherProcessName(isSubprocess)}.`, {cause: error});
|
|
41
|
-
|
|
42
|
-
// When using `strict` but the other process was not listening for messages
|
|
43
|
-
export const throwOnMissingStrict = isSubprocess => {
|
|
44
|
-
throw new Error(`${getMethodName('sendMessage', isSubprocess)} failed: the ${getOtherProcessName(isSubprocess)} is not listening to incoming messages.`);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// When using `strict` but the other process disconnected before receiving the message
|
|
48
|
-
export const throwOnStrictDisconnect = isSubprocess => {
|
|
49
|
-
throw new Error(`${getMethodName('sendMessage', isSubprocess)} failed: the ${getOtherProcessName(isSubprocess)} exited without listening to incoming messages.`);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// When the current process disconnects while the subprocess is listening to `cancelSignal`
|
|
53
|
-
export const getAbortDisconnectError = () => new Error(`\`cancelSignal\` aborted: the ${getOtherProcessName(true)} disconnected.`);
|
|
54
|
-
|
|
55
|
-
// When the subprocess uses `cancelSignal` but not the current process
|
|
56
|
-
export const throwOnMissingParent = () => {
|
|
57
|
-
throw new Error('`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.');
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// EPIPE can happen when sending a message to a subprocess that is closing but has not disconnected yet
|
|
61
|
-
export const handleEpipeError = ({error, methodName, isSubprocess}) => {
|
|
62
|
-
if (error.code === 'EPIPE') {
|
|
63
|
-
throw new Error(`${getMethodName(methodName, isSubprocess)} cannot be used: the ${getOtherProcessName(isSubprocess)} is disconnecting.`, {cause: error});
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// Better error message when sending messages which cannot be serialized.
|
|
68
|
-
// Works with both `serialization: 'advanced'` and `serialization: 'json'`.
|
|
69
|
-
export const handleSerializationError = ({error, methodName, isSubprocess, message}) => {
|
|
70
|
-
if (isSerializationError(error)) {
|
|
71
|
-
throw new Error(`${getMethodName(methodName, isSubprocess)}'s argument type is invalid: the message cannot be serialized: ${String(message)}.`, {cause: error});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const isSerializationError = ({code, message}) => SERIALIZATION_ERROR_CODES.has(code)
|
|
76
|
-
|| SERIALIZATION_ERROR_MESSAGES.some(serializationErrorMessage => message.includes(serializationErrorMessage));
|
|
77
|
-
|
|
78
|
-
// `error.code` set by Node.js when it failed to serialize the message
|
|
79
|
-
const SERIALIZATION_ERROR_CODES = new Set([
|
|
80
|
-
// Message is `undefined`
|
|
81
|
-
'ERR_MISSING_ARGS',
|
|
82
|
-
// Message is a function, a bigint, a symbol
|
|
83
|
-
'ERR_INVALID_ARG_TYPE',
|
|
84
|
-
]);
|
|
85
|
-
|
|
86
|
-
// `error.message` set by Node.js when it failed to serialize the message
|
|
87
|
-
const SERIALIZATION_ERROR_MESSAGES = [
|
|
88
|
-
// Message is a promise or a proxy, with `serialization: 'advanced'`
|
|
89
|
-
'could not be cloned',
|
|
90
|
-
// Message has cycles, with `serialization: 'json'`
|
|
91
|
-
'circular structure',
|
|
92
|
-
// Message has cycles inside toJSON(), with `serialization: 'json'`
|
|
93
|
-
'call stack size exceeded',
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
const getMethodName = (methodName, isSubprocess, parameters = '') => methodName === 'cancelSignal'
|
|
97
|
-
? '`cancelSignal`\'s `controller.abort()`'
|
|
98
|
-
: `${getNamespaceName(isSubprocess)}${methodName}(${parameters})`;
|
|
99
|
-
|
|
100
|
-
const getNamespaceName = isSubprocess => isSubprocess ? '' : 'subprocess.';
|
|
101
|
-
|
|
102
|
-
const getOtherProcessName = isSubprocess => isSubprocess ? 'parent process' : 'subprocess';
|
|
103
|
-
|
|
104
|
-
// When any error arises, we disconnect the IPC.
|
|
105
|
-
// Otherwise, it is likely that one of the processes will stop sending/receiving messages.
|
|
106
|
-
// This would leave the other process hanging.
|
|
107
|
-
export const disconnect = anyProcess => {
|
|
108
|
-
if (anyProcess.connected) {
|
|
109
|
-
anyProcess.disconnect();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import isPlainObject from 'is-plain-obj';
|
|
2
|
-
import {FD_SPECIFIC_OPTIONS} from '../arguments/specific.js';
|
|
3
|
-
|
|
4
|
-
// Deep merge specific options like `env`. Shallow merge the other ones.
|
|
5
|
-
export const mergeOptions = (boundOptions, options) => {
|
|
6
|
-
const newOptions = Object.fromEntries(
|
|
7
|
-
Object.entries(options).map(([optionName, optionValue]) => [
|
|
8
|
-
optionName,
|
|
9
|
-
mergeOption(optionName, boundOptions[optionName], optionValue),
|
|
10
|
-
]),
|
|
11
|
-
);
|
|
12
|
-
return {...boundOptions, ...newOptions};
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const mergeOption = (optionName, boundOptionValue, optionValue) => {
|
|
16
|
-
if (DEEP_OPTIONS.has(optionName) && isPlainObject(boundOptionValue) && isPlainObject(optionValue)) {
|
|
17
|
-
return {...boundOptionValue, ...optionValue};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return optionValue;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const DEEP_OPTIONS = new Set(['env', ...FD_SPECIFIC_OPTIONS]);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Main logic for `execaCommand()`
|
|
2
|
-
export const mapCommandAsync = ({file, commandArguments}) => parseCommand(file, commandArguments);
|
|
3
|
-
|
|
4
|
-
// Main logic for `execaCommandSync()`
|
|
5
|
-
export const mapCommandSync = ({file, commandArguments}) => ({...parseCommand(file, commandArguments), isSync: true});
|
|
6
|
-
|
|
7
|
-
// Convert `execaCommand(command)` into `execa(file, ...commandArguments)`
|
|
8
|
-
const parseCommand = (command, unusedArguments) => {
|
|
9
|
-
if (unusedArguments.length > 0) {
|
|
10
|
-
throw new TypeError(`The command and its arguments must be passed as a single string: ${command} ${unusedArguments}.`);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const [file, ...commandArguments] = parseCommandString(command);
|
|
14
|
-
return {file, commandArguments};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Convert `command` string into an array of file or arguments to pass to $`${...fileOrCommandArguments}`
|
|
18
|
-
export const parseCommandString = command => {
|
|
19
|
-
if (typeof command !== 'string') {
|
|
20
|
-
throw new TypeError(`The command must be a string: ${String(command)}.`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const trimmedCommand = command.trim();
|
|
24
|
-
if (trimmedCommand === '') {
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const tokens = [];
|
|
29
|
-
for (const token of trimmedCommand.split(SPACES_REGEXP)) {
|
|
30
|
-
// Allow spaces to be escaped by a backslash if not meant as a delimiter
|
|
31
|
-
const previousToken = tokens.at(-1);
|
|
32
|
-
if (previousToken && previousToken.endsWith('\\')) {
|
|
33
|
-
// Merge previous token with current one
|
|
34
|
-
tokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;
|
|
35
|
-
} else {
|
|
36
|
-
tokens.push(token);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return tokens;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const SPACES_REGEXP = / +/g;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import isPlainObject from 'is-plain-obj';
|
|
2
|
-
import {normalizeParameters} from './parameters.js';
|
|
3
|
-
import {isTemplateString, parseTemplates} from './template.js';
|
|
4
|
-
import {execaCoreSync} from './main-sync.js';
|
|
5
|
-
import {execaCoreAsync} from './main-async.js';
|
|
6
|
-
import {mergeOptions} from './bind.js';
|
|
7
|
-
|
|
8
|
-
// Wraps every exported methods to provide the following features:
|
|
9
|
-
// - template string syntax: execa`command argument`
|
|
10
|
-
// - options binding: boundExeca = execa(options)
|
|
11
|
-
// - optional argument/options: execa(file), execa(file, args), execa(file, options), execa(file, args, options)
|
|
12
|
-
// `mapArguments()` and `setBoundExeca()` allows for method-specific logic.
|
|
13
|
-
export const createExeca = (mapArguments, boundOptions, deepOptions, setBoundExeca) => {
|
|
14
|
-
const createNested = (mapArguments, boundOptions, setBoundExeca) => createExeca(mapArguments, boundOptions, deepOptions, setBoundExeca);
|
|
15
|
-
const boundExeca = (...execaArguments) => callBoundExeca({
|
|
16
|
-
mapArguments,
|
|
17
|
-
deepOptions,
|
|
18
|
-
boundOptions,
|
|
19
|
-
setBoundExeca,
|
|
20
|
-
createNested,
|
|
21
|
-
}, ...execaArguments);
|
|
22
|
-
|
|
23
|
-
if (setBoundExeca !== undefined) {
|
|
24
|
-
setBoundExeca(boundExeca, createNested, boundOptions);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return boundExeca;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const callBoundExeca = ({mapArguments, deepOptions = {}, boundOptions = {}, setBoundExeca, createNested}, firstArgument, ...nextArguments) => {
|
|
31
|
-
if (isPlainObject(firstArgument)) {
|
|
32
|
-
return createNested(mapArguments, mergeOptions(boundOptions, firstArgument), setBoundExeca);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const {file, commandArguments, options, isSync} = parseArguments({
|
|
36
|
-
mapArguments,
|
|
37
|
-
firstArgument,
|
|
38
|
-
nextArguments,
|
|
39
|
-
deepOptions,
|
|
40
|
-
boundOptions,
|
|
41
|
-
});
|
|
42
|
-
return isSync
|
|
43
|
-
? execaCoreSync(file, commandArguments, options)
|
|
44
|
-
: execaCoreAsync(file, commandArguments, options, createNested);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const parseArguments = ({mapArguments, firstArgument, nextArguments, deepOptions, boundOptions}) => {
|
|
48
|
-
const callArguments = isTemplateString(firstArgument)
|
|
49
|
-
? parseTemplates(firstArgument, nextArguments)
|
|
50
|
-
: [firstArgument, ...nextArguments];
|
|
51
|
-
const [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments);
|
|
52
|
-
const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions);
|
|
53
|
-
const {
|
|
54
|
-
file = initialFile,
|
|
55
|
-
commandArguments = initialArguments,
|
|
56
|
-
options = mergedOptions,
|
|
57
|
-
isSync = false,
|
|
58
|
-
} = mapArguments({file: initialFile, commandArguments: initialArguments, options: mergedOptions});
|
|
59
|
-
return {
|
|
60
|
-
file,
|
|
61
|
-
commandArguments,
|
|
62
|
-
options,
|
|
63
|
-
isSync,
|
|
64
|
-
};
|
|
65
|
-
};
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import {setMaxListeners} from 'node:events';
|
|
2
|
-
import {spawn} from 'node:child_process';
|
|
3
|
-
import {MaxBufferError} from 'get-stream';
|
|
4
|
-
import {handleCommand} from '../arguments/command.js';
|
|
5
|
-
import {normalizeOptions} from '../arguments/options.js';
|
|
6
|
-
import {SUBPROCESS_OPTIONS} from '../arguments/fd-options.js';
|
|
7
|
-
import {concatenateShell} from '../arguments/shell.js';
|
|
8
|
-
import {addIpcMethods} from '../ipc/methods.js';
|
|
9
|
-
import {makeError, makeSuccessResult} from '../return/result.js';
|
|
10
|
-
import {handleResult} from '../return/reject.js';
|
|
11
|
-
import {handleEarlyError} from '../return/early-error.js';
|
|
12
|
-
import {handleStdioAsync} from '../stdio/handle-async.js';
|
|
13
|
-
import {stripNewline} from '../io/strip-newline.js';
|
|
14
|
-
import {pipeOutputAsync} from '../io/output-async.js';
|
|
15
|
-
import {subprocessKill} from '../terminate/kill.js';
|
|
16
|
-
import {cleanupOnExit} from '../terminate/cleanup.js';
|
|
17
|
-
import {pipeToSubprocess} from '../pipe/setup.js';
|
|
18
|
-
import {makeAllStream} from '../resolve/all-async.js';
|
|
19
|
-
import {waitForSubprocessResult} from '../resolve/wait-subprocess.js';
|
|
20
|
-
import {addConvertedStreams} from '../convert/add.js';
|
|
21
|
-
import {createDeferred} from '../utils/deferred.js';
|
|
22
|
-
import {mergePromise} from './promise.js';
|
|
23
|
-
|
|
24
|
-
// Main shared logic for all async methods: `execa()`, `$`, `execaNode()`
|
|
25
|
-
export const execaCoreAsync = (rawFile, rawArguments, rawOptions, createNested) => {
|
|
26
|
-
const {file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleAsyncArguments(rawFile, rawArguments, rawOptions);
|
|
27
|
-
const {subprocess, promise} = spawnSubprocessAsync({
|
|
28
|
-
file,
|
|
29
|
-
commandArguments,
|
|
30
|
-
options,
|
|
31
|
-
startTime,
|
|
32
|
-
verboseInfo,
|
|
33
|
-
command,
|
|
34
|
-
escapedCommand,
|
|
35
|
-
fileDescriptors,
|
|
36
|
-
});
|
|
37
|
-
subprocess.pipe = pipeToSubprocess.bind(undefined, {
|
|
38
|
-
source: subprocess,
|
|
39
|
-
sourcePromise: promise,
|
|
40
|
-
boundOptions: {},
|
|
41
|
-
createNested,
|
|
42
|
-
});
|
|
43
|
-
mergePromise(subprocess, promise);
|
|
44
|
-
SUBPROCESS_OPTIONS.set(subprocess, {options, fileDescriptors});
|
|
45
|
-
return subprocess;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// Compute arguments to pass to `child_process.spawn()`
|
|
49
|
-
const handleAsyncArguments = (rawFile, rawArguments, rawOptions) => {
|
|
50
|
-
const {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArguments, rawOptions);
|
|
51
|
-
const {file, commandArguments, options: normalizedOptions} = normalizeOptions(rawFile, rawArguments, rawOptions);
|
|
52
|
-
const options = handleAsyncOptions(normalizedOptions);
|
|
53
|
-
const fileDescriptors = handleStdioAsync(options, verboseInfo);
|
|
54
|
-
return {
|
|
55
|
-
file,
|
|
56
|
-
commandArguments,
|
|
57
|
-
command,
|
|
58
|
-
escapedCommand,
|
|
59
|
-
startTime,
|
|
60
|
-
verboseInfo,
|
|
61
|
-
options,
|
|
62
|
-
fileDescriptors,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// Options normalization logic specific to async methods.
|
|
67
|
-
// Prevent passing the `timeout` option directly to `child_process.spawn()`.
|
|
68
|
-
const handleAsyncOptions = ({timeout, signal, ...options}) => {
|
|
69
|
-
if (signal !== undefined) {
|
|
70
|
-
throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return {...options, timeoutDuration: timeout};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const spawnSubprocessAsync = ({file, commandArguments, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors}) => {
|
|
77
|
-
let subprocess;
|
|
78
|
-
try {
|
|
79
|
-
subprocess = spawn(...concatenateShell(file, commandArguments, options));
|
|
80
|
-
} catch (error) {
|
|
81
|
-
return handleEarlyError({
|
|
82
|
-
error,
|
|
83
|
-
command,
|
|
84
|
-
escapedCommand,
|
|
85
|
-
fileDescriptors,
|
|
86
|
-
options,
|
|
87
|
-
startTime,
|
|
88
|
-
verboseInfo,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const controller = new AbortController();
|
|
93
|
-
setMaxListeners(Number.POSITIVE_INFINITY, controller.signal);
|
|
94
|
-
|
|
95
|
-
const originalStreams = [...subprocess.stdio];
|
|
96
|
-
pipeOutputAsync(subprocess, fileDescriptors, controller);
|
|
97
|
-
cleanupOnExit(subprocess, options, controller);
|
|
98
|
-
|
|
99
|
-
const context = {};
|
|
100
|
-
const onInternalError = createDeferred();
|
|
101
|
-
subprocess.kill = subprocessKill.bind(undefined, {
|
|
102
|
-
kill: subprocess.kill.bind(subprocess),
|
|
103
|
-
options,
|
|
104
|
-
onInternalError,
|
|
105
|
-
context,
|
|
106
|
-
controller,
|
|
107
|
-
});
|
|
108
|
-
subprocess.all = makeAllStream(subprocess, options);
|
|
109
|
-
addConvertedStreams(subprocess, options);
|
|
110
|
-
addIpcMethods(subprocess, options);
|
|
111
|
-
|
|
112
|
-
const promise = handlePromise({
|
|
113
|
-
subprocess,
|
|
114
|
-
options,
|
|
115
|
-
startTime,
|
|
116
|
-
verboseInfo,
|
|
117
|
-
fileDescriptors,
|
|
118
|
-
originalStreams,
|
|
119
|
-
command,
|
|
120
|
-
escapedCommand,
|
|
121
|
-
context,
|
|
122
|
-
onInternalError,
|
|
123
|
-
controller,
|
|
124
|
-
});
|
|
125
|
-
return {subprocess, promise};
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
// Asynchronous logic, as opposed to the previous logic which can be run synchronously, i.e. can be returned to user right away
|
|
129
|
-
const handlePromise = async ({subprocess, options, startTime, verboseInfo, fileDescriptors, originalStreams, command, escapedCommand, context, onInternalError, controller}) => {
|
|
130
|
-
const [
|
|
131
|
-
errorInfo,
|
|
132
|
-
[exitCode, signal],
|
|
133
|
-
stdioResults,
|
|
134
|
-
allResult,
|
|
135
|
-
ipcOutput,
|
|
136
|
-
] = await waitForSubprocessResult({
|
|
137
|
-
subprocess,
|
|
138
|
-
options,
|
|
139
|
-
context,
|
|
140
|
-
verboseInfo,
|
|
141
|
-
fileDescriptors,
|
|
142
|
-
originalStreams,
|
|
143
|
-
onInternalError,
|
|
144
|
-
controller,
|
|
145
|
-
});
|
|
146
|
-
controller.abort();
|
|
147
|
-
onInternalError.resolve();
|
|
148
|
-
|
|
149
|
-
const stdio = stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber));
|
|
150
|
-
const all = stripNewline(allResult, options, 'all');
|
|
151
|
-
const result = getAsyncResult({
|
|
152
|
-
errorInfo,
|
|
153
|
-
exitCode,
|
|
154
|
-
signal,
|
|
155
|
-
stdio,
|
|
156
|
-
all,
|
|
157
|
-
ipcOutput,
|
|
158
|
-
context,
|
|
159
|
-
options,
|
|
160
|
-
command,
|
|
161
|
-
escapedCommand,
|
|
162
|
-
startTime,
|
|
163
|
-
});
|
|
164
|
-
return handleResult(result, verboseInfo, options);
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const getAsyncResult = ({errorInfo, exitCode, signal, stdio, all, ipcOutput, context, options, command, escapedCommand, startTime}) => 'error' in errorInfo
|
|
168
|
-
? makeError({
|
|
169
|
-
error: errorInfo.error,
|
|
170
|
-
command,
|
|
171
|
-
escapedCommand,
|
|
172
|
-
timedOut: context.terminationReason === 'timeout',
|
|
173
|
-
isCanceled: context.terminationReason === 'cancel' || context.terminationReason === 'gracefulCancel',
|
|
174
|
-
isGracefullyCanceled: context.terminationReason === 'gracefulCancel',
|
|
175
|
-
isMaxBuffer: errorInfo.error instanceof MaxBufferError,
|
|
176
|
-
isForcefullyTerminated: context.isForcefullyTerminated,
|
|
177
|
-
exitCode,
|
|
178
|
-
signal,
|
|
179
|
-
stdio,
|
|
180
|
-
all,
|
|
181
|
-
ipcOutput,
|
|
182
|
-
options,
|
|
183
|
-
startTime,
|
|
184
|
-
isSync: false,
|
|
185
|
-
})
|
|
186
|
-
: makeSuccessResult({
|
|
187
|
-
command,
|
|
188
|
-
escapedCommand,
|
|
189
|
-
stdio,
|
|
190
|
-
all,
|
|
191
|
-
ipcOutput,
|
|
192
|
-
options,
|
|
193
|
-
startTime,
|
|
194
|
-
});
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import {spawnSync} from 'node:child_process';
|
|
2
|
-
import {handleCommand} from '../arguments/command.js';
|
|
3
|
-
import {normalizeOptions} from '../arguments/options.js';
|
|
4
|
-
import {concatenateShell} from '../arguments/shell.js';
|
|
5
|
-
import {makeError, makeEarlyError, makeSuccessResult} from '../return/result.js';
|
|
6
|
-
import {handleResult} from '../return/reject.js';
|
|
7
|
-
import {handleStdioSync} from '../stdio/handle-sync.js';
|
|
8
|
-
import {stripNewline} from '../io/strip-newline.js';
|
|
9
|
-
import {addInputOptionsSync} from '../io/input-sync.js';
|
|
10
|
-
import {transformOutputSync} from '../io/output-sync.js';
|
|
11
|
-
import {getMaxBufferSync} from '../io/max-buffer.js';
|
|
12
|
-
import {getAllSync} from '../resolve/all-sync.js';
|
|
13
|
-
import {getExitResultSync} from '../resolve/exit-sync.js';
|
|
14
|
-
|
|
15
|
-
// Main shared logic for all sync methods: `execaSync()`, `$.sync()`
|
|
16
|
-
export const execaCoreSync = (rawFile, rawArguments, rawOptions) => {
|
|
17
|
-
const {file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleSyncArguments(rawFile, rawArguments, rawOptions);
|
|
18
|
-
const result = spawnSubprocessSync({
|
|
19
|
-
file,
|
|
20
|
-
commandArguments,
|
|
21
|
-
options,
|
|
22
|
-
command,
|
|
23
|
-
escapedCommand,
|
|
24
|
-
verboseInfo,
|
|
25
|
-
fileDescriptors,
|
|
26
|
-
startTime,
|
|
27
|
-
});
|
|
28
|
-
return handleResult(result, verboseInfo, options);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// Compute arguments to pass to `child_process.spawnSync()`
|
|
32
|
-
const handleSyncArguments = (rawFile, rawArguments, rawOptions) => {
|
|
33
|
-
const {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArguments, rawOptions);
|
|
34
|
-
const syncOptions = normalizeSyncOptions(rawOptions);
|
|
35
|
-
const {file, commandArguments, options} = normalizeOptions(rawFile, rawArguments, syncOptions);
|
|
36
|
-
validateSyncOptions(options);
|
|
37
|
-
const fileDescriptors = handleStdioSync(options, verboseInfo);
|
|
38
|
-
return {
|
|
39
|
-
file,
|
|
40
|
-
commandArguments,
|
|
41
|
-
command,
|
|
42
|
-
escapedCommand,
|
|
43
|
-
startTime,
|
|
44
|
-
verboseInfo,
|
|
45
|
-
options,
|
|
46
|
-
fileDescriptors,
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Options normalization logic specific to sync methods
|
|
51
|
-
const normalizeSyncOptions = options => options.node && !options.ipc ? {...options, ipc: false} : options;
|
|
52
|
-
|
|
53
|
-
// Options validation logic specific to sync methods
|
|
54
|
-
const validateSyncOptions = ({ipc, ipcInput, detached, cancelSignal}) => {
|
|
55
|
-
if (ipcInput) {
|
|
56
|
-
throwInvalidSyncOption('ipcInput');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (ipc) {
|
|
60
|
-
throwInvalidSyncOption('ipc: true');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (detached) {
|
|
64
|
-
throwInvalidSyncOption('detached: true');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (cancelSignal) {
|
|
68
|
-
throwInvalidSyncOption('cancelSignal');
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const throwInvalidSyncOption = value => {
|
|
73
|
-
throw new TypeError(`The "${value}" option cannot be used with synchronous methods.`);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const spawnSubprocessSync = ({file, commandArguments, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime}) => {
|
|
77
|
-
const syncResult = runSubprocessSync({
|
|
78
|
-
file,
|
|
79
|
-
commandArguments,
|
|
80
|
-
options,
|
|
81
|
-
command,
|
|
82
|
-
escapedCommand,
|
|
83
|
-
fileDescriptors,
|
|
84
|
-
startTime,
|
|
85
|
-
});
|
|
86
|
-
if (syncResult.failed) {
|
|
87
|
-
return syncResult;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const {resultError, exitCode, signal, timedOut, isMaxBuffer} = getExitResultSync(syncResult, options);
|
|
91
|
-
const {output, error = resultError} = transformOutputSync({
|
|
92
|
-
fileDescriptors,
|
|
93
|
-
syncResult,
|
|
94
|
-
options,
|
|
95
|
-
isMaxBuffer,
|
|
96
|
-
verboseInfo,
|
|
97
|
-
});
|
|
98
|
-
const stdio = output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber));
|
|
99
|
-
const all = stripNewline(getAllSync(output, options), options, 'all');
|
|
100
|
-
return getSyncResult({
|
|
101
|
-
error,
|
|
102
|
-
exitCode,
|
|
103
|
-
signal,
|
|
104
|
-
timedOut,
|
|
105
|
-
isMaxBuffer,
|
|
106
|
-
stdio,
|
|
107
|
-
all,
|
|
108
|
-
options,
|
|
109
|
-
command,
|
|
110
|
-
escapedCommand,
|
|
111
|
-
startTime,
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const runSubprocessSync = ({file, commandArguments, options, command, escapedCommand, fileDescriptors, startTime}) => {
|
|
116
|
-
try {
|
|
117
|
-
addInputOptionsSync(fileDescriptors, options);
|
|
118
|
-
const normalizedOptions = normalizeSpawnSyncOptions(options);
|
|
119
|
-
return spawnSync(...concatenateShell(file, commandArguments, normalizedOptions));
|
|
120
|
-
} catch (error) {
|
|
121
|
-
return makeEarlyError({
|
|
122
|
-
error,
|
|
123
|
-
command,
|
|
124
|
-
escapedCommand,
|
|
125
|
-
fileDescriptors,
|
|
126
|
-
options,
|
|
127
|
-
startTime,
|
|
128
|
-
isSync: true,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// The `encoding` option is handled by Execa, not by `child_process.spawnSync()`
|
|
134
|
-
const normalizeSpawnSyncOptions = ({encoding, maxBuffer, ...options}) => ({...options, encoding: 'buffer', maxBuffer: getMaxBufferSync(maxBuffer)});
|
|
135
|
-
|
|
136
|
-
const getSyncResult = ({error, exitCode, signal, timedOut, isMaxBuffer, stdio, all, options, command, escapedCommand, startTime}) => error === undefined
|
|
137
|
-
? makeSuccessResult({
|
|
138
|
-
command,
|
|
139
|
-
escapedCommand,
|
|
140
|
-
stdio,
|
|
141
|
-
all,
|
|
142
|
-
ipcOutput: [],
|
|
143
|
-
options,
|
|
144
|
-
startTime,
|
|
145
|
-
})
|
|
146
|
-
: makeError({
|
|
147
|
-
error,
|
|
148
|
-
command,
|
|
149
|
-
escapedCommand,
|
|
150
|
-
timedOut,
|
|
151
|
-
isCanceled: false,
|
|
152
|
-
isGracefullyCanceled: false,
|
|
153
|
-
isMaxBuffer,
|
|
154
|
-
isForcefullyTerminated: false,
|
|
155
|
-
exitCode,
|
|
156
|
-
signal,
|
|
157
|
-
stdio,
|
|
158
|
-
all,
|
|
159
|
-
ipcOutput: [],
|
|
160
|
-
options,
|
|
161
|
-
startTime,
|
|
162
|
-
isSync: true,
|
|
163
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {execPath, execArgv} from 'node:process';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import {safeNormalizeFileUrl} from '../arguments/file-url.js';
|
|
4
|
-
|
|
5
|
-
// `execaNode()` is a shortcut for `execa(..., {node: true})`
|
|
6
|
-
export const mapNode = ({options}) => {
|
|
7
|
-
if (options.node === false) {
|
|
8
|
-
throw new TypeError('The "node" option cannot be false with `execaNode()`.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return {options: {...options, node: true}};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Applies the `node: true` option, and the related `nodePath`/`nodeOptions` options.
|
|
15
|
-
// Modifies the file commands/arguments to ensure the same Node binary and flags are re-used.
|
|
16
|
-
// Also adds `ipc: true` and `shell: false`.
|
|
17
|
-
export const handleNodeOption = (file, commandArguments, {
|
|
18
|
-
node: shouldHandleNode = false,
|
|
19
|
-
nodePath = execPath,
|
|
20
|
-
nodeOptions = execArgv.filter(nodeOption => !nodeOption.startsWith('--inspect')),
|
|
21
|
-
cwd,
|
|
22
|
-
execPath: formerNodePath,
|
|
23
|
-
...options
|
|
24
|
-
}) => {
|
|
25
|
-
if (formerNodePath !== undefined) {
|
|
26
|
-
throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const normalizedNodePath = safeNormalizeFileUrl(nodePath, 'The "nodePath" option');
|
|
30
|
-
const resolvedNodePath = path.resolve(cwd, normalizedNodePath);
|
|
31
|
-
const newOptions = {
|
|
32
|
-
...options,
|
|
33
|
-
nodePath: resolvedNodePath,
|
|
34
|
-
node: shouldHandleNode,
|
|
35
|
-
cwd,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
if (!shouldHandleNode) {
|
|
39
|
-
return [file, commandArguments, newOptions];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (path.basename(file, '.exe') === 'node') {
|
|
43
|
-
throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return [
|
|
47
|
-
resolvedNodePath,
|
|
48
|
-
[...nodeOptions, file, ...commandArguments],
|
|
49
|
-
{ipc: true, ...newOptions, shell: false},
|
|
50
|
-
];
|
|
51
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import isPlainObject from 'is-plain-obj';
|
|
2
|
-
import {safeNormalizeFileUrl} from '../arguments/file-url.js';
|
|
3
|
-
|
|
4
|
-
// The command `arguments` and `options` are both optional.
|
|
5
|
-
// This also does basic validation on them and on the command file.
|
|
6
|
-
export const normalizeParameters = (rawFile, rawArguments = [], rawOptions = {}) => {
|
|
7
|
-
const filePath = safeNormalizeFileUrl(rawFile, 'First argument');
|
|
8
|
-
const [commandArguments, options] = isPlainObject(rawArguments)
|
|
9
|
-
? [[], rawArguments]
|
|
10
|
-
: [rawArguments, rawOptions];
|
|
11
|
-
|
|
12
|
-
if (!Array.isArray(commandArguments)) {
|
|
13
|
-
throw new TypeError(`Second argument must be either an array of arguments or an options object: ${commandArguments}`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (commandArguments.some(commandArgument => typeof commandArgument === 'object' && commandArgument !== null)) {
|
|
17
|
-
throw new TypeError(`Second argument must be an array of strings: ${commandArguments}`);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const normalizedArguments = commandArguments.map(String);
|
|
21
|
-
const nullByteArgument = normalizedArguments.find(normalizedArgument => normalizedArgument.includes('\0'));
|
|
22
|
-
if (nullByteArgument !== undefined) {
|
|
23
|
-
throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${nullByteArgument}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!isPlainObject(options)) {
|
|
27
|
-
throw new TypeError(`Last argument must be an options object: ${options}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return [filePath, normalizedArguments, options];
|
|
31
|
-
};
|