@socketsecurity/cli-with-sentry 1.16.0 → 1.17.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/CHANGELOG.md +19 -0
- package/LICENSE +87 -0
- package/README.md +13 -13
- package/bin/cli.js +9 -9
- package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/cli.js +2120 -4305
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +71 -87
- package/dist/constants.js.map +1 -1
- package/dist/env-helpers.js +63 -0
- package/dist/env-helpers.js.map +1 -0
- package/dist/instrument-with-sentry.js +7 -7
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/manifest-scripts/dotnet-tool/Microsoft.Build.Locator.dll +0 -0
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.deps.json +2 -2
- package/dist/manifest-scripts/dotnet-tool/socket-facts-dotnet.dll +0 -0
- package/dist/manifest-scripts/maven-extension/coana-maven-extension.jar +0 -0
- package/dist/runtime-constants.js +345 -0
- package/dist/runtime-constants.js.map +1 -0
- package/dist/shadow-npm-bin2.js +9 -13
- package/dist/shadow-npm-bin2.js.map +1 -1
- package/dist/shadow-npm-inject.js +10 -15
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/shadow-npx-bin.js.map +1 -1
- package/dist/shadow-pnpm-bin2.js +21 -25
- package/dist/shadow-pnpm-bin2.js.map +1 -1
- package/dist/shadow-yarn-bin.js +4 -6
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/socket-completion.bash +0 -0
- package/dist/spawn-sync.js +47 -0
- package/dist/spawn-sync.js.map +1 -0
- package/dist/spinner.js +182 -0
- package/dist/spinner.js.map +1 -0
- package/dist/types/commands/fix/generated-socket-facts.d.mts +5 -2
- package/dist/types/commands/fix/handle-fix.d.mts +1 -1
- package/dist/types/commands/fix/types.d.mts +1 -1
- package/dist/types/commands/manifest/bazel/process.d.mts +2 -2
- package/dist/types/commands/manifest/convert-dotnet-to-facts.d.mts +3 -6
- package/dist/types/commands/manifest/discover-manifest-roots.d.mts +10 -11
- package/dist/types/commands/manifest/generate-recursive-manifests.d.mts +16 -30
- package/dist/types/commands/manifest/generate_auto_manifest.d.mts +6 -11
- package/dist/types/commands/manifest/load-build.d.mts +3 -11
- package/dist/types/commands/manifest/run-manifest-facts.d.mts +88 -29
- package/dist/types/commands/manifest/scripts/build-tool.d.mts +2 -0
- package/dist/types/commands/optimize/add-overrides.d.mts +2 -2
- package/dist/types/commands/optimize/get-dependency-entries.d.mts +1 -1
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +16 -7
- package/dist/types/commands/optimize/update-lockfile.d.mts +2 -2
- package/dist/types/commands/optimize/update-manifest-by-agent.d.mts +4 -2
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +2 -2
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +1 -1
- package/dist/types/commands/scan/generate-report.d.mts +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts +5 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts +1 -1
- package/dist/types/commands/scan/output-diff-scan.d.mts +4 -2
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +4 -6
- package/dist/types/commands/scan/run-dynamic-sbom-inference.d.mts +7 -15
- package/dist/types/constants/runtime.d.mts +417 -0
- package/dist/types/constants.d.mts +9 -10
- package/dist/types/paths/coana.d.mts +5 -0
- package/dist/types/paths/uv.d.mts +2 -0
- package/dist/types/sea/adapters/cdxgen-worker.d.mts +1 -0
- package/dist/types/sea/adapters/synp-worker.d.mts +1 -0
- package/dist/types/sea/build/cdxgen-fixture.d.mts +4 -0
- package/dist/types/sea/build/smoke-test.d.mts +2 -0
- package/dist/types/sea/build-sea.d.mts +4 -2
- package/dist/types/sea/download-bytes.d.mts +0 -1
- package/dist/types/sea/paths/archive.d.mts +3 -0
- package/dist/types/sea/paths/coana-cache.d.mts +1 -0
- package/dist/types/sea/paths/native-tools.d.mts +13 -0
- package/dist/types/sea/pnpm-lock.d.mts +22 -0
- package/dist/types/sea/rollup-workers.d.mts +1 -0
- package/dist/types/sea/runtime.d.mts +4 -3
- package/dist/types/sea/vfs-digest.d.mts +2 -0
- package/dist/types/shadow/common.d.mts +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -1
- package/dist/types/shadow/npm/bin.d.mts +1 -1
- package/dist/types/shadow/npm/install.d.mts +3 -3
- package/dist/types/shadow/npm-base.d.mts +1 -1
- package/dist/types/shadow/npx/bin.d.mts +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts +1 -1
- package/dist/types/shadow/yarn/bin.d.mts +1 -1
- package/dist/types/test/mocks/socket-auth.d.mts +40 -39
- package/dist/types/utils/agent.d.mts +6 -1
- package/dist/types/utils/alert/artifact.d.mts +1 -1
- package/dist/types/utils/alerts-map.d.mts +1 -1
- package/dist/types/utils/api.d.mts +1 -1
- package/dist/types/utils/arrays.d.mts +6 -0
- package/dist/types/utils/bin.d.mts +26 -0
- package/dist/types/utils/{coana-release.d.mts → coana/release.d.mts} +5 -3
- package/dist/types/utils/debug.d.mts +23 -49
- package/dist/types/utils/dlx.d.mts +1 -1
- package/dist/types/utils/ecosystem.d.mts +1 -9
- package/dist/types/utils/env.d.mts +24 -0
- package/dist/types/utils/errors.d.mts +2 -2
- package/dist/types/utils/escape-regexp.d.mts +6 -0
- package/dist/types/utils/fs.d.mts +33 -0
- package/dist/types/utils/github.d.mts +1 -1
- package/dist/types/utils/globs.d.mts +1 -0
- package/dist/types/utils/logger.d.mts +51 -0
- package/dist/types/utils/objects.d.mts +11 -0
- package/dist/types/utils/package-environment.d.mts +3 -3
- package/dist/types/utils/packages.d.mts +65 -0
- package/dist/types/utils/path.d.mts +3 -0
- package/dist/types/utils/promises.d.mts +23 -0
- package/dist/types/utils/prompts.d.mts +25 -0
- package/dist/types/utils/purl.d.mts +4 -1
- package/dist/types/utils/socket-package-alert.d.mts +1 -1
- package/dist/types/utils/socket-url.d.mts +1 -1
- package/dist/types/utils/sorts.d.mts +1 -0
- package/dist/types/utils/spawn-sync.d.mts +3 -0
- package/dist/types/utils/spawn.d.mts +67 -0
- package/dist/types/utils/spec.d.mts +1 -1
- package/dist/types/utils/spinner.d.mts +46 -0
- package/dist/types/utils/streams.d.mts +3 -0
- package/dist/types/utils/strings.d.mts +6 -0
- package/dist/types/utils/url.d.mts +2 -0
- package/dist/types/utils/words.d.mts +1 -0
- package/dist/utils.js +4481 -806
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +39737 -41318
- package/external/blessed-contrib/lib/widget/charts/line.js +172 -149
- package/package.json +43 -36
- package/shadow-bin/npm +0 -0
- package/shadow-bin/npx +0 -0
- package/shadow-bin/pnpm +0 -0
- package/shadow-bin/yarn +0 -0
- package/dist/types/commands/manifest/convert-gradle-to-facts.d.mts +0 -19
- package/dist/types/commands/manifest/convert-maven-to-facts.d.mts +0 -19
- package/dist/types/commands/manifest/convert-sbt-to-facts.d.mts +0 -22
- package/dist/types/commands/manifest/enumerate-workspaces.d.mts +0 -22
- package/dist/types/commands/manifest/expand-env-var-refs.d.mts +0 -9
- package/dist/types/sea/archive-paths.d.mts +0 -6
- package/external/@socketsecurity/registry/LICENSE +0 -21
- package/external/@socketsecurity/registry/README.md +0 -9
- package/external/@socketsecurity/registry/extensions.json +0 -28
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +0 -3165
- package/external/@socketsecurity/registry/external/@inquirer/input.js +0 -3202
- package/external/@socketsecurity/registry/external/@inquirer/password.js +0 -3307
- package/external/@socketsecurity/registry/external/@inquirer/search.js +0 -3519
- package/external/@socketsecurity/registry/external/@inquirer/select.js +0 -3655
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +0 -21406
- package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/read-package.js +0 -183
- package/external/@socketsecurity/registry/external/@npmcli/package-json/lib/sort.js +0 -274
- package/external/@socketsecurity/registry/external/@npmcli/promise-spawn.js +0 -704
- package/external/@socketsecurity/registry/external/@socketregistry/is-unicode-supported.js +0 -54
- package/external/@socketsecurity/registry/external/@socketregistry/packageurl-js.js +0 -4516
- package/external/@socketsecurity/registry/external/@socketregistry/yocto-spinner.js +0 -453
- package/external/@socketsecurity/registry/external/@yarnpkg/extensions.js +0 -1406
- package/external/@socketsecurity/registry/external/browserslist.js +0 -20496
- package/external/@socketsecurity/registry/external/cacache.js +0 -16208
- package/external/@socketsecurity/registry/external/debug.js +0 -1163
- package/external/@socketsecurity/registry/external/fast-glob.js +0 -7994
- package/external/@socketsecurity/registry/external/fast-sort.js +0 -181
- package/external/@socketsecurity/registry/external/libnpmpack.js +0 -106271
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +0 -38997
- package/external/@socketsecurity/registry/external/normalize-package-data.js +0 -5343
- package/external/@socketsecurity/registry/external/npm-package-arg.js +0 -5773
- package/external/@socketsecurity/registry/external/pacote.js +0 -74109
- package/external/@socketsecurity/registry/external/picomatch.js +0 -2307
- package/external/@socketsecurity/registry/external/semver.js +0 -2618
- package/external/@socketsecurity/registry/external/signal-exit.js +0 -336
- package/external/@socketsecurity/registry/external/spdx-correct.js +0 -1457
- package/external/@socketsecurity/registry/external/spdx-expression-parse.js +0 -1043
- package/external/@socketsecurity/registry/external/streaming-iterables.js +0 -326
- package/external/@socketsecurity/registry/external/validate-npm-package-name.js +0 -108
- package/external/@socketsecurity/registry/external/which.js +0 -405
- package/external/@socketsecurity/registry/external/yoctocolors-cjs.js +0 -101
- package/external/@socketsecurity/registry/index.js +0 -31
- package/external/@socketsecurity/registry/lib/agent.js +0 -390
- package/external/@socketsecurity/registry/lib/arrays.js +0 -89
- package/external/@socketsecurity/registry/lib/bin.js +0 -650
- package/external/@socketsecurity/registry/lib/constants/abort-controller.js +0 -15
- package/external/@socketsecurity/registry/lib/constants/abort-signal.js +0 -27
- package/external/@socketsecurity/registry/lib/constants/at-latest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/biome-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/bun.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ci.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/column-limit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/copy-left-licenses.js +0 -27
- package/external/@socketsecurity/registry/lib/constants/darwin.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-package-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/empty-file.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/empty-value.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/env.js +0 -59
- package/external/@socketsecurity/registry/lib/constants/eslint-config-js.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/esnext.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/exec-path.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cmd.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-dts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-js.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-lockb.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-md.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-mjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-mts.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-ps1.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/extensions-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/extensions.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/get-ipc.js +0 -10
- package/external/@socketsecurity/registry/lib/constants/gitignore.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/index.js +0 -139
- package/external/@socketsecurity/registry/lib/constants/ipc-handler.js +0 -19
- package/external/@socketsecurity/registry/lib/constants/ipc-object.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/ipc-promise.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/ipc-target.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/k-internals-symbol.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/latest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license-original.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/license.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/lifecycle-script-names.js +0 -18
- package/external/@socketsecurity/registry/lib/constants/loop-sentinel.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/maintained-node-versions.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/manifest-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/mit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-auth-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-debug-flags.js +0 -9
- package/external/@socketsecurity/registry/lib/constants/node-env.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-harden-flags.js +0 -29
- package/external/@socketsecurity/registry/lib/constants/node-modules-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-modules.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/node-no-warnings-flags.js +0 -16
- package/external/@socketsecurity/registry/lib/constants/node-version.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/npx.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/overrides.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-default-node-range.js +0 -6
- package/external/@socketsecurity/registry/lib/constants/package-default-socket-categories.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-default-version.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-extensions.js +0 -47
- package/external/@socketsecurity/registry/lib/constants/package-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/package-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/packument-cache.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pacote-cache-path.js +0 -9
- package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pnpm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/pre-commit.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-glob-recursive.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-glob.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/readme-md.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/registry-scope-delimiter.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/registry.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/resolutions.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-github-org.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-ipc-handshake.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-override-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-public-api-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-npm-org.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-package-name.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-repo-name.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-registry-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/socket-security-scope.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/spinner.js +0 -4
- package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-api.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-compile-cache-env-var.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-disable-warning-flag.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-permission-flag.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-node-require-module.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/supports-node-run.js +0 -8
- package/external/@socketsecurity/registry/lib/constants/supports-process-send.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/ts-libs-available.js +0 -22
- package/external/@socketsecurity/registry/lib/constants/ts-types-available.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/tsconfig-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/undefined-token.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unknown-error.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unknown-value.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unlicenced.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/unlicensed.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/utf8.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vitest.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/vlt.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/win32.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +0 -5
- package/external/@socketsecurity/registry/lib/constants/yarn-lock.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/yarn.js +0 -3
- package/external/@socketsecurity/registry/lib/debug.js +0 -264
- package/external/@socketsecurity/registry/lib/env.js +0 -62
- package/external/@socketsecurity/registry/lib/fs.js +0 -556
- package/external/@socketsecurity/registry/lib/functions.js +0 -20
- package/external/@socketsecurity/registry/lib/globs.js +0 -145
- package/external/@socketsecurity/registry/lib/json.js +0 -69
- package/external/@socketsecurity/registry/lib/logger.js +0 -534
- package/external/@socketsecurity/registry/lib/objects.js +0 -422
- package/external/@socketsecurity/registry/lib/packages.js +0 -1379
- package/external/@socketsecurity/registry/lib/path.js +0 -231
- package/external/@socketsecurity/registry/lib/promises.js +0 -286
- package/external/@socketsecurity/registry/lib/prompts.js +0 -63
- package/external/@socketsecurity/registry/lib/regexps.js +0 -23
- package/external/@socketsecurity/registry/lib/sorts.js +0 -70
- package/external/@socketsecurity/registry/lib/spawn.js +0 -252
- package/external/@socketsecurity/registry/lib/spinner.js +0 -205
- package/external/@socketsecurity/registry/lib/streams.js +0 -84
- package/external/@socketsecurity/registry/lib/strings.js +0 -235
- package/external/@socketsecurity/registry/lib/url.js +0 -68
- package/external/@socketsecurity/registry/lib/words.js +0 -45
- package/external/@socketsecurity/registry/manifest.json +0 -1875
|
@@ -1,704 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const require$$0$1 = require('child_process')
|
|
4
|
-
const require$$1$2 = require('os')
|
|
5
|
-
const require$$0 = require('fs')
|
|
6
|
-
const require$$1 = require('fs/promises')
|
|
7
|
-
const require$$1$1 = require('path')
|
|
8
|
-
|
|
9
|
-
const cjs = {}
|
|
10
|
-
|
|
11
|
-
const posix = {}
|
|
12
|
-
|
|
13
|
-
let hasRequiredPosix
|
|
14
|
-
function requirePosix() {
|
|
15
|
-
if (hasRequiredPosix) {
|
|
16
|
-
return posix
|
|
17
|
-
}
|
|
18
|
-
hasRequiredPosix = 1
|
|
19
|
-
/**
|
|
20
|
-
* This is the Posix implementation of isexe, which uses the file
|
|
21
|
-
* mode and uid/gid values.
|
|
22
|
-
*
|
|
23
|
-
* @module
|
|
24
|
-
*/
|
|
25
|
-
Object.defineProperty(posix, '__esModule', {
|
|
26
|
-
value: true
|
|
27
|
-
})
|
|
28
|
-
posix.sync = posix.isexe = void 0
|
|
29
|
-
const fs_1 = require$$0
|
|
30
|
-
const promises_1 = require$$1
|
|
31
|
-
/**
|
|
32
|
-
* Determine whether a path is executable according to the mode and
|
|
33
|
-
* current (or specified) user and group IDs.
|
|
34
|
-
*/
|
|
35
|
-
const isexe = async (path, options = {}) => {
|
|
36
|
-
const { ignoreErrors = false } = options
|
|
37
|
-
try {
|
|
38
|
-
return checkStat(await (0, promises_1.stat)(path), options)
|
|
39
|
-
} catch (e) {
|
|
40
|
-
const er = e
|
|
41
|
-
if (ignoreErrors || er.code === 'EACCES') {
|
|
42
|
-
return false
|
|
43
|
-
}
|
|
44
|
-
throw er
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
posix.isexe = isexe
|
|
48
|
-
/**
|
|
49
|
-
* Synchronously determine whether a path is executable according to
|
|
50
|
-
* the mode and current (or specified) user and group IDs.
|
|
51
|
-
*/
|
|
52
|
-
const sync = (path, options = {}) => {
|
|
53
|
-
const { ignoreErrors = false } = options
|
|
54
|
-
try {
|
|
55
|
-
return checkStat((0, fs_1.statSync)(path), options)
|
|
56
|
-
} catch (e) {
|
|
57
|
-
const er = e
|
|
58
|
-
if (ignoreErrors || er.code === 'EACCES') {
|
|
59
|
-
return false
|
|
60
|
-
}
|
|
61
|
-
throw er
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
posix.sync = sync
|
|
65
|
-
const checkStat = (stat, options) => stat.isFile() && checkMode(stat, options)
|
|
66
|
-
const checkMode = (stat, options) => {
|
|
67
|
-
const myUid = options.uid ?? process.getuid?.()
|
|
68
|
-
const myGroups = options.groups ?? process.getgroups?.() ?? []
|
|
69
|
-
const myGid = options.gid ?? process.getgid?.() ?? myGroups[0]
|
|
70
|
-
if (myUid === undefined || myGid === undefined) {
|
|
71
|
-
throw new Error('cannot get uid or gid')
|
|
72
|
-
}
|
|
73
|
-
const groups = new Set([myGid, ...myGroups])
|
|
74
|
-
const mod = stat.mode
|
|
75
|
-
const uid = stat.uid
|
|
76
|
-
const gid = stat.gid
|
|
77
|
-
const u = parseInt('100', 8)
|
|
78
|
-
const g = parseInt('010', 8)
|
|
79
|
-
const o = parseInt('001', 8)
|
|
80
|
-
const ug = u | g
|
|
81
|
-
return !!(
|
|
82
|
-
mod & o ||
|
|
83
|
-
(mod & g && groups.has(gid)) ||
|
|
84
|
-
(mod & u && uid === myUid) ||
|
|
85
|
-
(mod & ug && myUid === 0)
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
return posix
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const win32 = {}
|
|
92
|
-
|
|
93
|
-
let hasRequiredWin32
|
|
94
|
-
function requireWin32() {
|
|
95
|
-
if (hasRequiredWin32) {
|
|
96
|
-
return win32
|
|
97
|
-
}
|
|
98
|
-
hasRequiredWin32 = 1
|
|
99
|
-
/**
|
|
100
|
-
* This is the Windows implementation of isexe, which uses the file
|
|
101
|
-
* extension and PATHEXT setting.
|
|
102
|
-
*
|
|
103
|
-
* @module
|
|
104
|
-
*/
|
|
105
|
-
Object.defineProperty(win32, '__esModule', {
|
|
106
|
-
value: true
|
|
107
|
-
})
|
|
108
|
-
win32.sync = win32.isexe = void 0
|
|
109
|
-
const fs_1 = require$$0
|
|
110
|
-
const promises_1 = require$$1
|
|
111
|
-
/**
|
|
112
|
-
* Determine whether a path is executable based on the file extension
|
|
113
|
-
* and PATHEXT environment variable (or specified pathExt option)
|
|
114
|
-
*/
|
|
115
|
-
const isexe = async (path, options = {}) => {
|
|
116
|
-
const { ignoreErrors = false } = options
|
|
117
|
-
try {
|
|
118
|
-
return checkStat(await (0, promises_1.stat)(path), path, options)
|
|
119
|
-
} catch (e) {
|
|
120
|
-
const er = e
|
|
121
|
-
if (ignoreErrors || er.code === 'EACCES') {
|
|
122
|
-
return false
|
|
123
|
-
}
|
|
124
|
-
throw er
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
win32.isexe = isexe
|
|
128
|
-
/**
|
|
129
|
-
* Synchronously determine whether a path is executable based on the file
|
|
130
|
-
* extension and PATHEXT environment variable (or specified pathExt option)
|
|
131
|
-
*/
|
|
132
|
-
const sync = (path, options = {}) => {
|
|
133
|
-
const { ignoreErrors = false } = options
|
|
134
|
-
try {
|
|
135
|
-
return checkStat((0, fs_1.statSync)(path), path, options)
|
|
136
|
-
} catch (e) {
|
|
137
|
-
const er = e
|
|
138
|
-
if (ignoreErrors || er.code === 'EACCES') {
|
|
139
|
-
return false
|
|
140
|
-
}
|
|
141
|
-
throw er
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
win32.sync = sync
|
|
145
|
-
const checkPathExt = (path, options) => {
|
|
146
|
-
const { pathExt = process.env.PATHEXT || '' } = options
|
|
147
|
-
const peSplit = pathExt.split(';')
|
|
148
|
-
if (peSplit.indexOf('') !== -1) {
|
|
149
|
-
return true
|
|
150
|
-
}
|
|
151
|
-
for (let i = 0; i < peSplit.length; i++) {
|
|
152
|
-
const p = peSplit[i].toLowerCase()
|
|
153
|
-
const ext = path.substring(path.length - p.length).toLowerCase()
|
|
154
|
-
if (p && ext === p) {
|
|
155
|
-
return true
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return false
|
|
159
|
-
}
|
|
160
|
-
const checkStat = (stat, path, options) =>
|
|
161
|
-
stat.isFile() && checkPathExt(path, options)
|
|
162
|
-
return win32
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const options = {}
|
|
166
|
-
|
|
167
|
-
let hasRequiredOptions
|
|
168
|
-
function requireOptions() {
|
|
169
|
-
if (hasRequiredOptions) {
|
|
170
|
-
return options
|
|
171
|
-
}
|
|
172
|
-
hasRequiredOptions = 1
|
|
173
|
-
Object.defineProperty(options, '__esModule', {
|
|
174
|
-
value: true
|
|
175
|
-
})
|
|
176
|
-
return options
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
let hasRequiredCjs
|
|
180
|
-
function requireCjs() {
|
|
181
|
-
if (hasRequiredCjs) {
|
|
182
|
-
return cjs
|
|
183
|
-
}
|
|
184
|
-
hasRequiredCjs = 1
|
|
185
|
-
;(function (exports) {
|
|
186
|
-
const __createBinding =
|
|
187
|
-
(this && this.__createBinding) ||
|
|
188
|
-
(Object.create
|
|
189
|
-
? function (o, m, k, k2) {
|
|
190
|
-
if (k2 === undefined) {
|
|
191
|
-
k2 = k
|
|
192
|
-
}
|
|
193
|
-
let desc = Object.getOwnPropertyDescriptor(m, k)
|
|
194
|
-
if (
|
|
195
|
-
!desc ||
|
|
196
|
-
('get' in desc
|
|
197
|
-
? !m.__esModule
|
|
198
|
-
: desc.writable || desc.configurable)
|
|
199
|
-
) {
|
|
200
|
-
desc = {
|
|
201
|
-
enumerable: true,
|
|
202
|
-
get: function () {
|
|
203
|
-
return m[k]
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
Object.defineProperty(o, k2, desc)
|
|
208
|
-
}
|
|
209
|
-
: function (o, m, k, k2) {
|
|
210
|
-
if (k2 === undefined) {
|
|
211
|
-
k2 = k
|
|
212
|
-
}
|
|
213
|
-
o[k2] = m[k]
|
|
214
|
-
})
|
|
215
|
-
const __setModuleDefault =
|
|
216
|
-
(this && this.__setModuleDefault) ||
|
|
217
|
-
(Object.create
|
|
218
|
-
? function (o, v) {
|
|
219
|
-
Object.defineProperty(o, 'default', {
|
|
220
|
-
enumerable: true,
|
|
221
|
-
value: v
|
|
222
|
-
})
|
|
223
|
-
}
|
|
224
|
-
: function (o, v) {
|
|
225
|
-
o['default'] = v
|
|
226
|
-
})
|
|
227
|
-
const __importStar =
|
|
228
|
-
(this && this.__importStar) ||
|
|
229
|
-
function (mod) {
|
|
230
|
-
if (mod && mod.__esModule) {
|
|
231
|
-
return mod
|
|
232
|
-
}
|
|
233
|
-
const result = {}
|
|
234
|
-
if (mod != null) {
|
|
235
|
-
for (var k in mod)
|
|
236
|
-
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k))
|
|
237
|
-
__createBinding(result, mod, k)
|
|
238
|
-
}
|
|
239
|
-
__setModuleDefault(result, mod)
|
|
240
|
-
return result
|
|
241
|
-
}
|
|
242
|
-
const __exportStar =
|
|
243
|
-
(this && this.__exportStar) ||
|
|
244
|
-
function (m, exports) {
|
|
245
|
-
for (const p in m) {
|
|
246
|
-
if (
|
|
247
|
-
p !== 'default' &&
|
|
248
|
-
!Object.prototype.hasOwnProperty.call(exports, p)
|
|
249
|
-
)
|
|
250
|
-
__createBinding(exports, m, p)
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
Object.defineProperty(exports, '__esModule', {
|
|
254
|
-
value: true
|
|
255
|
-
})
|
|
256
|
-
exports.sync = exports.isexe = exports.posix = exports.win32 = void 0
|
|
257
|
-
const posix = __importStar(requirePosix())
|
|
258
|
-
exports.posix = posix
|
|
259
|
-
const win32 = __importStar(requireWin32())
|
|
260
|
-
exports.win32 = win32
|
|
261
|
-
__exportStar(requireOptions(), exports)
|
|
262
|
-
const platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform
|
|
263
|
-
const impl = platform === 'win32' ? win32 : posix
|
|
264
|
-
/**
|
|
265
|
-
* Determine whether a path is executable on the current platform.
|
|
266
|
-
*/
|
|
267
|
-
exports.isexe = impl.isexe
|
|
268
|
-
/**
|
|
269
|
-
* Synchronously determine whether a path is executable on the
|
|
270
|
-
* current platform.
|
|
271
|
-
*/
|
|
272
|
-
exports.sync = impl.sync
|
|
273
|
-
})(cjs)
|
|
274
|
-
return cjs
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
let lib$1
|
|
278
|
-
let hasRequiredLib$1
|
|
279
|
-
function requireLib$1() {
|
|
280
|
-
if (hasRequiredLib$1) {
|
|
281
|
-
return lib$1
|
|
282
|
-
}
|
|
283
|
-
hasRequiredLib$1 = 1
|
|
284
|
-
const { isexe, sync: isexeSync } = requireCjs()
|
|
285
|
-
const { join, delimiter, sep, posix } = require$$1$1
|
|
286
|
-
const isWindows = process.platform === 'win32'
|
|
287
|
-
|
|
288
|
-
// used to check for slashed in commands passed in. always checks for the posix
|
|
289
|
-
// seperator on all platforms, and checks for the current separator when not on
|
|
290
|
-
// a posix platform. don't use the isWindows check for this since that is mocked
|
|
291
|
-
// in tests but we still need the code to actually work when called. that is also
|
|
292
|
-
// why it is ignored from coverage.
|
|
293
|
-
/* istanbul ignore next */
|
|
294
|
-
const rSlash = new RegExp(
|
|
295
|
-
`[${posix.sep}${sep === posix.sep ? '' : sep}]`.replace(/(\\)/g, '\\$1')
|
|
296
|
-
)
|
|
297
|
-
const rRel = new RegExp(`^\\.${rSlash.source}`)
|
|
298
|
-
const getNotFoundError = cmd =>
|
|
299
|
-
Object.assign(new Error(`not found: ${cmd}`), {
|
|
300
|
-
code: 'ENOENT'
|
|
301
|
-
})
|
|
302
|
-
const getPathInfo = (
|
|
303
|
-
cmd,
|
|
304
|
-
{
|
|
305
|
-
path: optPath = process.env.PATH,
|
|
306
|
-
pathExt: optPathExt = process.env.PATHEXT,
|
|
307
|
-
delimiter: optDelimiter = delimiter
|
|
308
|
-
}
|
|
309
|
-
) => {
|
|
310
|
-
// If it has a slash, then we don't bother searching the pathenv.
|
|
311
|
-
// just check the file itself, and that's it.
|
|
312
|
-
const pathEnv = cmd.match(rSlash)
|
|
313
|
-
? ['']
|
|
314
|
-
: [
|
|
315
|
-
// windows always checks the cwd first
|
|
316
|
-
...(isWindows ? [process.cwd()] : []),
|
|
317
|
-
...(optPath || /* istanbul ignore next: very unusual */ '').split(
|
|
318
|
-
optDelimiter
|
|
319
|
-
)
|
|
320
|
-
]
|
|
321
|
-
if (isWindows) {
|
|
322
|
-
const pathExtExe =
|
|
323
|
-
optPathExt || ['.EXE', '.CMD', '.BAT', '.COM'].join(optDelimiter)
|
|
324
|
-
const pathExt = pathExtExe
|
|
325
|
-
.split(optDelimiter)
|
|
326
|
-
.flatMap(item => [item, item.toLowerCase()])
|
|
327
|
-
if (cmd.includes('.') && pathExt[0] !== '') {
|
|
328
|
-
pathExt.unshift('')
|
|
329
|
-
}
|
|
330
|
-
return {
|
|
331
|
-
pathEnv,
|
|
332
|
-
pathExt,
|
|
333
|
-
pathExtExe
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return {
|
|
337
|
-
pathEnv,
|
|
338
|
-
pathExt: ['']
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
const getPathPart = (raw, cmd) => {
|
|
342
|
-
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw
|
|
343
|
-
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : ''
|
|
344
|
-
return prefix + join(pathPart, cmd)
|
|
345
|
-
}
|
|
346
|
-
const which = async (cmd, opt = {}) => {
|
|
347
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
348
|
-
const found = []
|
|
349
|
-
for (const envPart of pathEnv) {
|
|
350
|
-
const p = getPathPart(envPart, cmd)
|
|
351
|
-
for (const ext of pathExt) {
|
|
352
|
-
const withExt = p + ext
|
|
353
|
-
const is = await isexe(withExt, {
|
|
354
|
-
pathExt: pathExtExe,
|
|
355
|
-
ignoreErrors: true
|
|
356
|
-
})
|
|
357
|
-
if (is) {
|
|
358
|
-
if (!opt.all) {
|
|
359
|
-
return withExt
|
|
360
|
-
}
|
|
361
|
-
found.push(withExt)
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
if (opt.all && found.length) {
|
|
366
|
-
return found
|
|
367
|
-
}
|
|
368
|
-
if (opt.nothrow) {
|
|
369
|
-
return null
|
|
370
|
-
}
|
|
371
|
-
throw getNotFoundError(cmd)
|
|
372
|
-
}
|
|
373
|
-
const whichSync = (cmd, opt = {}) => {
|
|
374
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
375
|
-
const found = []
|
|
376
|
-
for (const pathEnvPart of pathEnv) {
|
|
377
|
-
const p = getPathPart(pathEnvPart, cmd)
|
|
378
|
-
for (const ext of pathExt) {
|
|
379
|
-
const withExt = p + ext
|
|
380
|
-
const is = isexeSync(withExt, {
|
|
381
|
-
pathExt: pathExtExe,
|
|
382
|
-
ignoreErrors: true
|
|
383
|
-
})
|
|
384
|
-
if (is) {
|
|
385
|
-
if (!opt.all) {
|
|
386
|
-
return withExt
|
|
387
|
-
}
|
|
388
|
-
found.push(withExt)
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
if (opt.all && found.length) {
|
|
393
|
-
return found
|
|
394
|
-
}
|
|
395
|
-
if (opt.nothrow) {
|
|
396
|
-
return null
|
|
397
|
-
}
|
|
398
|
-
throw getNotFoundError(cmd)
|
|
399
|
-
}
|
|
400
|
-
lib$1 = which
|
|
401
|
-
which.sync = whichSync
|
|
402
|
-
return lib$1
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
let _escape
|
|
406
|
-
let hasRequired_escape
|
|
407
|
-
function require_escape() {
|
|
408
|
-
if (hasRequired_escape) {
|
|
409
|
-
return _escape
|
|
410
|
-
}
|
|
411
|
-
hasRequired_escape = 1
|
|
412
|
-
|
|
413
|
-
// eslint-disable-next-line max-len
|
|
414
|
-
// this code adapted from: https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
|
|
415
|
-
const cmd = (input, doubleEscape) => {
|
|
416
|
-
if (!input.length) {
|
|
417
|
-
return '""'
|
|
418
|
-
}
|
|
419
|
-
let result
|
|
420
|
-
if (!/[ \t\n\v"]/.test(input)) {
|
|
421
|
-
result = input
|
|
422
|
-
} else {
|
|
423
|
-
result = '"'
|
|
424
|
-
for (let i = 0; i <= input.length; ++i) {
|
|
425
|
-
let slashCount = 0
|
|
426
|
-
while (input[i] === '\\') {
|
|
427
|
-
++i
|
|
428
|
-
++slashCount
|
|
429
|
-
}
|
|
430
|
-
if (i === input.length) {
|
|
431
|
-
result += '\\'.repeat(slashCount * 2)
|
|
432
|
-
break
|
|
433
|
-
}
|
|
434
|
-
if (input[i] === '"') {
|
|
435
|
-
result += '\\'.repeat(slashCount * 2 + 1)
|
|
436
|
-
result += input[i]
|
|
437
|
-
} else {
|
|
438
|
-
result += '\\'.repeat(slashCount)
|
|
439
|
-
result += input[i]
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
result += '"'
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// and finally, prefix shell meta chars with a ^
|
|
446
|
-
result = result.replace(/[ !%^&()<>|"]/g, '^$&')
|
|
447
|
-
if (doubleEscape) {
|
|
448
|
-
result = result.replace(/[ !%^&()<>|"]/g, '^$&')
|
|
449
|
-
}
|
|
450
|
-
return result
|
|
451
|
-
}
|
|
452
|
-
const sh = input => {
|
|
453
|
-
if (!input.length) {
|
|
454
|
-
return `''`
|
|
455
|
-
}
|
|
456
|
-
if (!/[\t\n\r "#$&'()*;<>?\\`|~]/.test(input)) {
|
|
457
|
-
return input
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// replace single quotes with '\'' and wrap the whole result in a fresh set of quotes
|
|
461
|
-
const result = `'${input.replace(/'/g, `'\\''`)}'`
|
|
462
|
-
// if the input string already had single quotes around it, clean those up
|
|
463
|
-
.replace(/^(?:'')+(?!$)/, '')
|
|
464
|
-
.replace(/\\'''/g, `\\'`)
|
|
465
|
-
return result
|
|
466
|
-
}
|
|
467
|
-
_escape = {
|
|
468
|
-
cmd,
|
|
469
|
-
sh
|
|
470
|
-
}
|
|
471
|
-
return _escape
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
let lib
|
|
475
|
-
let hasRequiredLib
|
|
476
|
-
function requireLib() {
|
|
477
|
-
if (hasRequiredLib) {
|
|
478
|
-
return lib
|
|
479
|
-
}
|
|
480
|
-
hasRequiredLib = 1
|
|
481
|
-
const { spawn } = require$$0$1
|
|
482
|
-
const os = require$$1$2
|
|
483
|
-
const which = requireLib$1()
|
|
484
|
-
const escape = require_escape()
|
|
485
|
-
|
|
486
|
-
// 'extra' object is for decorating the error a bit more
|
|
487
|
-
const promiseSpawn = (cmd, args, opts = {}, extra = {}) => {
|
|
488
|
-
if (opts.shell) {
|
|
489
|
-
return spawnWithShell(cmd, args, opts, extra)
|
|
490
|
-
}
|
|
491
|
-
let resolve, reject
|
|
492
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
493
|
-
resolve = _resolve
|
|
494
|
-
reject = _reject
|
|
495
|
-
})
|
|
496
|
-
|
|
497
|
-
// Create error here so we have a more useful stack trace when rejecting
|
|
498
|
-
const closeError = new Error('command failed')
|
|
499
|
-
const stdout = []
|
|
500
|
-
const stderr = []
|
|
501
|
-
const getResult = result => ({
|
|
502
|
-
cmd,
|
|
503
|
-
args,
|
|
504
|
-
...result,
|
|
505
|
-
...stdioResult(stdout, stderr, opts),
|
|
506
|
-
...extra
|
|
507
|
-
})
|
|
508
|
-
const rejectWithOpts = (er, erOpts) => {
|
|
509
|
-
const resultError = getResult(erOpts)
|
|
510
|
-
reject(Object.assign(er, resultError))
|
|
511
|
-
}
|
|
512
|
-
const proc = spawn(cmd, args, opts)
|
|
513
|
-
promise.stdin = proc.stdin
|
|
514
|
-
promise.process = proc
|
|
515
|
-
proc.on('error', rejectWithOpts)
|
|
516
|
-
if (proc.stdout) {
|
|
517
|
-
proc.stdout.on('data', c => stdout.push(c))
|
|
518
|
-
proc.stdout.on('error', rejectWithOpts)
|
|
519
|
-
}
|
|
520
|
-
if (proc.stderr) {
|
|
521
|
-
proc.stderr.on('data', c => stderr.push(c))
|
|
522
|
-
proc.stderr.on('error', rejectWithOpts)
|
|
523
|
-
}
|
|
524
|
-
proc.on('close', (code, signal) => {
|
|
525
|
-
if (code || signal) {
|
|
526
|
-
rejectWithOpts(closeError, {
|
|
527
|
-
code,
|
|
528
|
-
signal
|
|
529
|
-
})
|
|
530
|
-
} else {
|
|
531
|
-
resolve(
|
|
532
|
-
getResult({
|
|
533
|
-
code,
|
|
534
|
-
signal
|
|
535
|
-
})
|
|
536
|
-
)
|
|
537
|
-
}
|
|
538
|
-
})
|
|
539
|
-
return promise
|
|
540
|
-
}
|
|
541
|
-
const spawnWithShell = (cmd, args, opts, extra) => {
|
|
542
|
-
let command = opts.shell
|
|
543
|
-
// if shell is set to true, we use a platform default. we can't let the core
|
|
544
|
-
// spawn method decide this for us because we need to know what shell is in use
|
|
545
|
-
// ahead of time so that we can escape arguments properly. we don't need coverage here.
|
|
546
|
-
if (command === true) {
|
|
547
|
-
// istanbul ignore next
|
|
548
|
-
command =
|
|
549
|
-
process.platform === 'win32' ? process.env.ComSpec || 'cmd.exe' : 'sh'
|
|
550
|
-
}
|
|
551
|
-
const options = {
|
|
552
|
-
...opts,
|
|
553
|
-
shell: false
|
|
554
|
-
}
|
|
555
|
-
const realArgs = []
|
|
556
|
-
let script = cmd
|
|
557
|
-
|
|
558
|
-
// first, determine if we're in windows because if we are we need to know if we're
|
|
559
|
-
// running an .exe or a .cmd/.bat since the latter requires extra escaping
|
|
560
|
-
const isCmd = /(?:^|\\)cmd(?:\.exe)?$/i.test(command)
|
|
561
|
-
if (isCmd) {
|
|
562
|
-
let doubleEscape = false
|
|
563
|
-
|
|
564
|
-
// find the actual command we're running
|
|
565
|
-
let initialCmd = ''
|
|
566
|
-
let insideQuotes = false
|
|
567
|
-
for (let i = 0; i < cmd.length; ++i) {
|
|
568
|
-
const char = cmd.charAt(i)
|
|
569
|
-
if (char === ' ' && !insideQuotes) {
|
|
570
|
-
break
|
|
571
|
-
}
|
|
572
|
-
initialCmd += char
|
|
573
|
-
if (char === '"' || char === "'") {
|
|
574
|
-
insideQuotes = !insideQuotes
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
let pathToInitial
|
|
578
|
-
try {
|
|
579
|
-
pathToInitial = which
|
|
580
|
-
.sync(initialCmd, {
|
|
581
|
-
path:
|
|
582
|
-
(options.env && findInObject(options.env, 'PATH')) ||
|
|
583
|
-
process.env.PATH,
|
|
584
|
-
pathext:
|
|
585
|
-
(options.env && findInObject(options.env, 'PATHEXT')) ||
|
|
586
|
-
process.env.PATHEXT
|
|
587
|
-
})
|
|
588
|
-
.toLowerCase()
|
|
589
|
-
} catch (err) {
|
|
590
|
-
pathToInitial = initialCmd.toLowerCase()
|
|
591
|
-
}
|
|
592
|
-
doubleEscape =
|
|
593
|
-
pathToInitial.endsWith('.cmd') || pathToInitial.endsWith('.bat')
|
|
594
|
-
for (const arg of args) {
|
|
595
|
-
script += ` ${escape.cmd(arg, doubleEscape)}`
|
|
596
|
-
}
|
|
597
|
-
realArgs.push('/d', '/s', '/c', script)
|
|
598
|
-
options.windowsVerbatimArguments = true
|
|
599
|
-
} else {
|
|
600
|
-
for (const arg of args) {
|
|
601
|
-
script += ` ${escape.sh(arg)}`
|
|
602
|
-
}
|
|
603
|
-
realArgs.push('-c', script)
|
|
604
|
-
}
|
|
605
|
-
return promiseSpawn(command, realArgs, options, extra)
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// open a file with the default application as defined by the user's OS
|
|
609
|
-
const open = (_args, opts = {}, extra = {}) => {
|
|
610
|
-
const options = {
|
|
611
|
-
...opts,
|
|
612
|
-
shell: true
|
|
613
|
-
}
|
|
614
|
-
const args = [].concat(_args)
|
|
615
|
-
let platform = process.platform
|
|
616
|
-
// process.platform === 'linux' may actually indicate WSL, if that's the case
|
|
617
|
-
// open the argument with sensible-browser which is pre-installed
|
|
618
|
-
// In WSL, set the default browser using, for example,
|
|
619
|
-
// export BROWSER="/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"
|
|
620
|
-
// or
|
|
621
|
-
// export BROWSER="/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
622
|
-
// To permanently set the default browser, add the appropriate entry to your shell's
|
|
623
|
-
// RC file, e.g. .bashrc or .zshrc.
|
|
624
|
-
if (
|
|
625
|
-
platform === 'linux' &&
|
|
626
|
-
os.release().toLowerCase().includes('microsoft')
|
|
627
|
-
) {
|
|
628
|
-
platform = 'wsl'
|
|
629
|
-
if (!process.env.BROWSER) {
|
|
630
|
-
return Promise.reject(
|
|
631
|
-
new Error(
|
|
632
|
-
'Set the BROWSER environment variable to your desired browser.'
|
|
633
|
-
)
|
|
634
|
-
)
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
let command = options.command
|
|
638
|
-
if (!command) {
|
|
639
|
-
if (platform === 'win32') {
|
|
640
|
-
// spawnWithShell does not do the additional os.release() check, so we
|
|
641
|
-
// have to force the shell here to make sure we treat WSL as windows.
|
|
642
|
-
options.shell = process.env.ComSpec
|
|
643
|
-
// also, the start command accepts a title so to make sure that we don't
|
|
644
|
-
// accidentally interpret the first arg as the title, we stick an empty
|
|
645
|
-
// string immediately after the start command
|
|
646
|
-
command = 'start ""'
|
|
647
|
-
} else if (platform === 'wsl') {
|
|
648
|
-
command = 'sensible-browser'
|
|
649
|
-
} else if (platform === 'darwin') {
|
|
650
|
-
command = 'open'
|
|
651
|
-
} else {
|
|
652
|
-
command = 'xdg-open'
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
return spawnWithShell(command, args, options, extra)
|
|
656
|
-
}
|
|
657
|
-
promiseSpawn.open = open
|
|
658
|
-
const isPipe = (stdio = 'pipe', fd) => {
|
|
659
|
-
if (stdio === 'pipe' || stdio === null) {
|
|
660
|
-
return true
|
|
661
|
-
}
|
|
662
|
-
if (Array.isArray(stdio)) {
|
|
663
|
-
return isPipe(stdio[fd], fd)
|
|
664
|
-
}
|
|
665
|
-
return false
|
|
666
|
-
}
|
|
667
|
-
const stdioResult = (stdout, stderr, { stdioString = true, stdio }) => {
|
|
668
|
-
const result = {
|
|
669
|
-
stdout: null,
|
|
670
|
-
stderr: null
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// stdio is [stdin, stdout, stderr]
|
|
674
|
-
if (isPipe(stdio, 1)) {
|
|
675
|
-
result.stdout = Buffer.concat(stdout)
|
|
676
|
-
if (stdioString) {
|
|
677
|
-
result.stdout = result.stdout.toString().trim()
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
if (isPipe(stdio, 2)) {
|
|
681
|
-
result.stderr = Buffer.concat(stderr)
|
|
682
|
-
if (stdioString) {
|
|
683
|
-
result.stderr = result.stderr.toString().trim()
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
return result
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
// case insensitive lookup in an object
|
|
690
|
-
const findInObject = (obj, key) => {
|
|
691
|
-
key = key.toLowerCase()
|
|
692
|
-
for (const objKey of Object.keys(obj).sort()) {
|
|
693
|
-
if (objKey.toLowerCase() === key) {
|
|
694
|
-
return obj[objKey]
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
lib = promiseSpawn
|
|
699
|
-
return lib
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
const libExports = requireLib()
|
|
703
|
-
|
|
704
|
-
module.exports = libExports
|