@vltpkg/cli-js 1.4.0 → 1.6.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/{access-422UGEWN.js → access-AJ654YKY.js} +13 -12
- package/{bugs-RED7Y33Q.js → bugs-N73DVYHD.js} +32 -25
- package/{build-IHMPBWRO.js → build-VZ3EZKMM.js} +65 -21
- package/{cache-FJP2RZJX.js → cache-VROEWG2C.js} +20 -17
- package/cache-unzip-src-unzip.js +58 -15
- package/{chunk-TPRK6IDA.js → chunk-22LZBDEC.js} +2 -2
- package/chunk-36UIE654.js +6248 -0
- package/{chunk-UGCKF5ZE.js → chunk-3JIN46K5.js} +1 -1
- package/{chunk-OAJ3PO3Z.js → chunk-44AWMA4F.js} +25 -13
- package/chunk-4E65BBTM.js +77 -0
- package/{chunk-SR2VOY5J.js → chunk-4GMNWW4C.js} +1 -1
- package/{chunk-5IJTPZXP.js → chunk-6D3QAFNZ.js} +1 -1
- package/{chunk-X4FVR4R5.js → chunk-75HGJVNG.js} +12 -10
- package/{chunk-THSYN5EK.js → chunk-7M2VTFLP.js} +12 -1
- package/{chunk-2AMOC4DN.js → chunk-ANW36H4T.js} +4 -4
- package/chunk-B6RIGNEO.js +626 -0
- package/{chunk-FLH4YC6W.js → chunk-BF5DRGRZ.js} +60 -15
- package/chunk-BH5CVXNY.js +115 -0
- package/{chunk-PLG3OYCX.js → chunk-CAV7FKWQ.js} +3 -2
- package/{chunk-C23TDXRG.js → chunk-CYK6I4M6.js} +1 -1
- package/chunk-DXED4ARV.js +436 -0
- package/chunk-E74WGW5C.js +49 -0
- package/{chunk-WF6KLKRN.js → chunk-EFHOWRKU.js} +103 -1
- package/chunk-EMTGRCSE.js +1111 -0
- package/{chunk-5Y4SYLJ2.js → chunk-EYGOEAJM.js} +1 -1
- package/{chunk-OVPHE4O7.js → chunk-F5LZMLAQ.js} +5335 -10902
- package/{chunk-HZXJ423P.js → chunk-FXD3IV2S.js} +4 -2
- package/chunk-GCTREKA4.js +115 -0
- package/{chunk-ZJMJ7MCT.js → chunk-GEQFMH5M.js} +1 -1
- package/{chunk-ISE4IRHF.js → chunk-GZVI75KX.js} +7 -14
- package/chunk-HOF7LEIC.js +24 -0
- package/{chunk-LHPEBLOU.js → chunk-HT6FS4VB.js} +1 -1
- package/{chunk-PHJJPY5G.js → chunk-IXAMCWIT.js} +5 -5
- package/{chunk-ASLX43R3.js → chunk-JCNI6ZHH.js} +7 -5
- package/chunk-JV5XR5JQ.js +349 -0
- package/{chunk-7T3XAYP4.js → chunk-KD5ZK72K.js} +1 -1
- package/{chunk-FZUYGJZU.js → chunk-KVWGMSPW.js} +137 -19
- package/{chunk-TO23PR7J.js → chunk-LCLRP64K.js} +14 -12
- package/{chunk-QCSUWACA.js → chunk-LGQVZTYR.js} +8 -36
- package/{chunk-5RHABCYI.js → chunk-LP3ORD3D.js} +143 -17
- package/chunk-MCDLJZXT.js +82 -0
- package/{chunk-DNRR3XMG.js → chunk-N6HV7JWC.js} +1 -1
- package/chunk-O6MQ7NN6.js +1155 -0
- package/{chunk-GIIAODRI.js → chunk-PC2HOBAQ.js} +7 -5
- package/{chunk-APMYKJI2.js → chunk-QNHBAGXQ.js} +1 -1
- package/chunk-RBQO54TG.js +59 -0
- package/chunk-SUU2WETN.js +268 -0
- package/{chunk-I7UMHYZX.js → chunk-TQQO2F56.js} +113 -1187
- package/{chunk-4UCADW6S.js → chunk-TWDSXQPN.js} +9 -7
- package/{chunk-MKWPTN3C.js → chunk-VLVMLSIF.js} +2 -2
- package/chunk-W4T5CGCO.js +52 -0
- package/{chunk-5TNXLRW2.js → chunk-YTDABXPD.js} +50 -12
- package/{ci-YSKNNO5M.js → ci-3BVMVQIT.js} +35 -13
- package/cli-package.json +3 -1
- package/{config-HO7GY3QT.js → config-2KQV7N5A.js} +16 -13
- package/{config-CSPCDMR3.js → config-EKHBW6I5.js} +12 -9
- package/{create-2TJT3AHJ.js → create-QVHNOIV3.js} +35 -29
- package/{deprecate-7FRJI2RL.js → deprecate-E254QBH6.js} +17 -15
- package/{dist-tag-WCFF5OEG.js → dist-tag-SITRFD7O.js} +13 -12
- package/{docs-JMBPTU23.js → docs-IDL2P7CA.js} +32 -25
- package/{exec-FBOUKZZ2.js → exec-7BK2W2WL.js} +35 -29
- package/{exec-cache-X3ZWM5S3.js → exec-cache-VY46L7DR.js} +27 -21
- package/{exec-local-Y3KQC22N.js → exec-local-D7R5T3DF.js} +26 -20
- package/{help-PUKVH5X7.js → help-RMRIEJQL.js} +6 -5
- package/{init-GOKAQXXZ.js → init-BGW4HJ6V.js} +15 -11
- package/{install-XFN4UFOC.js → install-U5GATZ2N.js} +144 -49
- package/{list-43JFFG5D.js → list-3VG4M2XL.js} +41 -28
- package/{login-RSTZKNKN.js → login-PHQWI6S6.js} +19 -16
- package/{logout-4576FFXZ.js → logout-DJCOGRFF.js} +13 -12
- package/{outdated-ACQ5A2Y7.js → outdated-JH3O6R3Y.js} +27 -22
- package/{pack-QQVJ3G25.js → pack-U5W5YWHK.js} +23 -18
- package/package.json +1 -1
- package/{ping-QCDQQRO5.js → ping-EKX43AOW.js} +13 -12
- package/{pkg-CSOJV7UC.js → pkg-SW5GMERT.js} +19 -14
- package/{profile-VL4HPW3N.js → profile-UGDRDMQ6.js} +13 -12
- package/{publish-2YBO6ZXE.js → publish-HTWKK3NN.js} +60 -45
- package/{query-IHHFMJRT.js → query-YE3FUVGG.js} +43 -30
- package/{registry-W7BRZZZ2.js → registry-ZGGWVLBM.js} +7 -7
- package/registry-client-src-revalidate.js +76 -22
- package/{repo-L3BXAAWS.js → repo-WDOCU6SE.js} +32 -25
- package/{reporter-5NYOHBO7.js → reporter-N5PAXB26.js} +121 -17
- package/{run-AMUUVLTI.js → run-IPARVIIQ.js} +26 -20
- package/{run-exec-5W3XWQZA.js → run-exec-C4RTREEW.js} +26 -20
- package/security-archive-src-update-expired.js +66 -21
- package/{setup-TFM4GJF7.js → setup-SYYUEHZL.js} +212 -32
- package/skills-KA2VR5Q5.js +480 -0
- package/skills-UBBMSBDQ.js +416 -0
- package/{src-4CYCUWZL.js → src-FUSTSM4J.js} +33 -22
- package/{src-I3GMULFP.js → src-QO5G2S4O.js} +11 -8
- package/{src-LUTN2ODD.js → src-W2VQULRG.js} +2 -2
- package/{token-OANOBE3G.js → token-UQNABECH.js} +15 -13
- package/{uninstall-YXTQ4AIZ.js → uninstall-FHBJ3OUV.js} +59 -18
- package/{unpublish-SZXYMYIU.js → unpublish-APJTEUBA.js} +31 -16
- package/{update-FHLMWGIM.js → update-NWZTL4S7.js} +52 -25
- package/{version-ZWFCTU5V.js → version-EMKKTL77.js} +20 -14
- package/{view-NFNJXMLV.js → view-BUUI33RV.js} +17 -15
- package/vlr.js +1 -1
- package/vlrx.js +1 -1
- package/vlt.js +1 -1
- package/vlx.js +1 -1
- package/vlxl.js +1 -1
- package/{whoami-O7GOSGCI.js → whoami-F6BSXGQ2.js} +13 -12
- package/chunk-G2YT2GWF.js +0 -120
- package/chunk-T6FBP4OU.js +0 -76
- package/chunk-U7TEQCBN.js +0 -880
|
@@ -12,16 +12,17 @@ var require = _vlt_createRequire(import.meta.filename);
|
|
|
12
12
|
import {
|
|
13
13
|
init,
|
|
14
14
|
install
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-36UIE654.js";
|
|
16
16
|
import {
|
|
17
17
|
commandUsage
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HT6FS4VB.js";
|
|
19
19
|
import {
|
|
20
20
|
assertWSConfig,
|
|
21
|
+
migratableWSConfig,
|
|
21
22
|
minimatch,
|
|
22
23
|
resolveWSConfig,
|
|
23
24
|
splitNegatedPatterns
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TQQO2F56.js";
|
|
25
26
|
import {
|
|
26
27
|
load,
|
|
27
28
|
save
|
|
@@ -75,11 +76,12 @@ Modify/add properties using \`vlt pkg\`. For example:
|
|
|
75
76
|
var command = async (conf) => {
|
|
76
77
|
const allowScripts = conf.get("allow-scripts") ? String(conf.get("allow-scripts")) : ":not(*)";
|
|
77
78
|
if (conf.values.workspace?.length) {
|
|
78
|
-
const
|
|
79
|
+
const resolved = resolveWSConfig(
|
|
79
80
|
conf.options.projectRoot,
|
|
80
81
|
conf.options.packageJson
|
|
81
82
|
);
|
|
82
|
-
const
|
|
83
|
+
const parsedWSConfig = resolved.config;
|
|
84
|
+
const workspacesConfig = load("workspaces", assertWSConfig) ?? migratableWSConfig(resolved);
|
|
83
85
|
const results = [];
|
|
84
86
|
const addToConfig = [];
|
|
85
87
|
for (const workspace of conf.values.workspace) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var global = globalThis;
|
|
2
|
+
import {Buffer} from "node:buffer";
|
|
3
|
+
import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
|
|
4
|
+
globalThis.setTimeout = _vlt_setTimeout;
|
|
5
|
+
globalThis.clearTimeout = _vlt_clearTimeout;
|
|
6
|
+
globalThis.setImmediate = _vlt_setImmediate;
|
|
7
|
+
globalThis.clearImmediate = _vlt_clearImmediate;
|
|
8
|
+
globalThis.setInterval = _vlt_setInterval;
|
|
9
|
+
globalThis.clearInterval = _vlt_clearInterval;
|
|
10
|
+
import {createRequire as _vlt_createRequire} from "node:module";
|
|
11
|
+
var require = _vlt_createRequire(import.meta.filename);
|
|
12
|
+
import {
|
|
13
|
+
stderr
|
|
14
|
+
} from "./chunk-KVWGMSPW.js";
|
|
15
|
+
import {
|
|
16
|
+
migratableWSConfig,
|
|
17
|
+
resolveWSConfig
|
|
18
|
+
} from "./chunk-TQQO2F56.js";
|
|
19
|
+
import {
|
|
20
|
+
save
|
|
21
|
+
} from "./chunk-HTOTG4TS.js";
|
|
22
|
+
|
|
23
|
+
// ../../src/cli-sdk/src/migrate-workspaces.ts
|
|
24
|
+
var found = (conf) => {
|
|
25
|
+
const resolved = resolveWSConfig(
|
|
26
|
+
conf.options.projectRoot,
|
|
27
|
+
conf.options.packageJson,
|
|
28
|
+
false
|
|
29
|
+
);
|
|
30
|
+
const workspaces = migratableWSConfig(resolved);
|
|
31
|
+
const { source } = resolved;
|
|
32
|
+
if (!workspaces?.length || !source) return;
|
|
33
|
+
return { source, workspaces };
|
|
34
|
+
};
|
|
35
|
+
var migrateWorkspaces = (conf) => {
|
|
36
|
+
if (!conf.options["migrate-workspaces"]) return;
|
|
37
|
+
const migrated = found(conf);
|
|
38
|
+
if (migrated) save("workspaces", migrated.workspaces);
|
|
39
|
+
return migrated;
|
|
40
|
+
};
|
|
41
|
+
var warnIgnoredWorkspaces = (conf) => {
|
|
42
|
+
const { loglevel } = conf.values;
|
|
43
|
+
if (loglevel === "silent" || loglevel === "error") return;
|
|
44
|
+
let migrated;
|
|
45
|
+
try {
|
|
46
|
+
migrated = found(conf);
|
|
47
|
+
} catch {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!migrated) return;
|
|
51
|
+
stderr(
|
|
52
|
+
`Warning: vlt ci reads workspaces from vlt.json only; ignoring ${migrated.source}, its workspaces are not installed. Run \`vlt install\` to save them to vlt.json, or add them there.`
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
migrateWorkspaces,
|
|
58
|
+
warnIgnoredWorkspaces
|
|
59
|
+
};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
var global = globalThis;
|
|
2
|
+
import {Buffer} from "node:buffer";
|
|
3
|
+
import {setTimeout as _vlt_setTimeout,clearTimeout as _vlt_clearTimeout,setImmediate as _vlt_setImmediate,clearImmediate as _vlt_clearImmediate,setInterval as _vlt_setInterval,clearInterval as _vlt_clearInterval} from "node:timers";
|
|
4
|
+
globalThis.setTimeout = _vlt_setTimeout;
|
|
5
|
+
globalThis.clearTimeout = _vlt_clearTimeout;
|
|
6
|
+
globalThis.setImmediate = _vlt_setImmediate;
|
|
7
|
+
globalThis.clearImmediate = _vlt_clearImmediate;
|
|
8
|
+
globalThis.setInterval = _vlt_setInterval;
|
|
9
|
+
globalThis.clearInterval = _vlt_clearInterval;
|
|
10
|
+
import {createRequire as _vlt_createRequire} from "node:module";
|
|
11
|
+
var require = _vlt_createRequire(import.meta.filename);
|
|
12
|
+
import {
|
|
13
|
+
error
|
|
14
|
+
} from "./chunk-WZWDS3W4.js";
|
|
15
|
+
|
|
16
|
+
// ../../src/promise-spawn/src/index.ts
|
|
17
|
+
import { spawn } from "node:child_process";
|
|
18
|
+
var isPipe = (stdio = "pipe", fd) => stdio === "pipe" || stdio === "overlapped" || stdio === null ? true : Array.isArray(stdio) ? isPipe(stdio[fd], fd) : false;
|
|
19
|
+
function stdioResult(stdout, stderr, o) {
|
|
20
|
+
return {
|
|
21
|
+
stdout: !isPipe(o.stdio, 1) ? null : o.stdioString !== false ? Buffer.concat(stdout).toString().trim() : Buffer.concat(stdout),
|
|
22
|
+
stderr: !isPipe(o.stdio, 2) ? null : o.stdioString !== false ? Buffer.concat(stderr).toString().trim() : Buffer.concat(stderr)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var SpawnPromise = class extends Promise {
|
|
26
|
+
[Symbol.toStringTag] = "SpawnPromise";
|
|
27
|
+
/** The spawned process this promise references */
|
|
28
|
+
process;
|
|
29
|
+
/** Expose the child process stdin, if available */
|
|
30
|
+
stdin;
|
|
31
|
+
/**
|
|
32
|
+
* Set static `Symbol.species` back to the base Promise class so that
|
|
33
|
+
* v8 doesn't get confused by the changed constructor signature.
|
|
34
|
+
*/
|
|
35
|
+
static get [Symbol.species]() {
|
|
36
|
+
return Promise;
|
|
37
|
+
}
|
|
38
|
+
constructor(command, args, opts, extra = {}) {
|
|
39
|
+
let proc;
|
|
40
|
+
super((res, rej) => {
|
|
41
|
+
proc = spawn(command, args, opts);
|
|
42
|
+
const stdout = [];
|
|
43
|
+
const stderr = [];
|
|
44
|
+
const reject = (er, status, signal) => {
|
|
45
|
+
const stdio = stdioResult(stdout, stderr, opts);
|
|
46
|
+
const errorResult = {
|
|
47
|
+
command,
|
|
48
|
+
args,
|
|
49
|
+
stdout: stdio.stdout,
|
|
50
|
+
stderr: stdio.stderr,
|
|
51
|
+
cwd: opts.cwd?.toString() ?? process.cwd()
|
|
52
|
+
};
|
|
53
|
+
if (er !== void 0) {
|
|
54
|
+
errorResult.cause = er;
|
|
55
|
+
}
|
|
56
|
+
if (status !== void 0) {
|
|
57
|
+
errorResult.status = status;
|
|
58
|
+
}
|
|
59
|
+
if (signal !== void 0) {
|
|
60
|
+
errorResult.signal = signal;
|
|
61
|
+
}
|
|
62
|
+
Object.assign(errorResult, extra);
|
|
63
|
+
rej(error("command failed", errorResult));
|
|
64
|
+
};
|
|
65
|
+
const resolve = (status, signal) => {
|
|
66
|
+
const stdio = stdioResult(stdout, stderr, opts);
|
|
67
|
+
const successResult = {
|
|
68
|
+
command,
|
|
69
|
+
args,
|
|
70
|
+
status,
|
|
71
|
+
signal,
|
|
72
|
+
stdout: stdio.stdout,
|
|
73
|
+
stderr: stdio.stderr,
|
|
74
|
+
cwd: opts.cwd?.toString() ?? process.cwd()
|
|
75
|
+
};
|
|
76
|
+
Object.assign(successResult, extra);
|
|
77
|
+
res(successResult);
|
|
78
|
+
};
|
|
79
|
+
proc.on("error", reject);
|
|
80
|
+
proc.stdout?.on("data", (c) => stdout.push(c)).on("error", reject);
|
|
81
|
+
proc.stderr?.on("data", (c) => stderr.push(c)).on("error", reject);
|
|
82
|
+
proc.on("close", (status, signal) => {
|
|
83
|
+
if ((status || signal) && !opts.acceptFail) {
|
|
84
|
+
reject(void 0, status, signal);
|
|
85
|
+
} else {
|
|
86
|
+
resolve(status, signal);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
this.process = proc;
|
|
91
|
+
this.stdin = proc.stdin;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
function promiseSpawn(command, args, opts = {}, extra = {}) {
|
|
95
|
+
return new SpawnPromise(command, args, opts, extra);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ../../node_modules/.vlt/~npm~isexe@3.1.5/node_modules/isexe/dist/esm/index.min.js
|
|
99
|
+
import { statSync as w } from "node:fs";
|
|
100
|
+
import { stat as S } from "node:fs/promises";
|
|
101
|
+
import { statSync as k } from "node:fs";
|
|
102
|
+
import { stat as I } from "node:fs/promises";
|
|
103
|
+
import { delimiter as _ } from "node:path";
|
|
104
|
+
var y = Object.defineProperty;
|
|
105
|
+
var u = (t, r) => {
|
|
106
|
+
for (var e in r) y(t, e, { get: r[e], enumerable: true });
|
|
107
|
+
};
|
|
108
|
+
var i = {};
|
|
109
|
+
u(i, { isexe: () => C, sync: () => A });
|
|
110
|
+
var C = async (t, r = {}) => {
|
|
111
|
+
let { ignoreErrors: e = false } = r;
|
|
112
|
+
try {
|
|
113
|
+
return d(await S(t), r);
|
|
114
|
+
} catch (s) {
|
|
115
|
+
let o = s;
|
|
116
|
+
if (e || o.code === "EACCES") return false;
|
|
117
|
+
throw o;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
var A = (t, r = {}) => {
|
|
121
|
+
let { ignoreErrors: e = false } = r;
|
|
122
|
+
try {
|
|
123
|
+
return d(w(t), r);
|
|
124
|
+
} catch (s) {
|
|
125
|
+
let o = s;
|
|
126
|
+
if (e || o.code === "EACCES") return false;
|
|
127
|
+
throw o;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var d = (t, r) => t.isFile() && T(t, r);
|
|
131
|
+
var T = (t, r) => {
|
|
132
|
+
let e = r.uid ?? process.getuid?.(), s = r.groups ?? process.getgroups?.() ?? [], o = r.gid ?? process.getgid?.() ?? s[0];
|
|
133
|
+
if (e === void 0 || o === void 0) throw new Error("cannot get uid or gid");
|
|
134
|
+
let c = /* @__PURE__ */ new Set([o, ...s]), n = t.mode, l = t.uid, E = t.gid, f = parseInt("100", 8), p = parseInt("010", 8), x = parseInt("001", 8), h = f | p;
|
|
135
|
+
return !!(n & x || n & p && c.has(E) || n & f && l === e || n & h && e === 0);
|
|
136
|
+
};
|
|
137
|
+
var a = {};
|
|
138
|
+
u(a, { isexe: () => F, sync: () => L });
|
|
139
|
+
var F = async (t, r = {}) => {
|
|
140
|
+
let { ignoreErrors: e = false } = r;
|
|
141
|
+
try {
|
|
142
|
+
return m(await I(t), t, r);
|
|
143
|
+
} catch (s) {
|
|
144
|
+
let o = s;
|
|
145
|
+
if (e || o.code === "EACCES") return false;
|
|
146
|
+
throw o;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var L = (t, r = {}) => {
|
|
150
|
+
let { ignoreErrors: e = false } = r;
|
|
151
|
+
try {
|
|
152
|
+
return m(k(t), t, r);
|
|
153
|
+
} catch (s) {
|
|
154
|
+
let o = s;
|
|
155
|
+
if (e || o.code === "EACCES") return false;
|
|
156
|
+
throw o;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var P = (t, r) => {
|
|
160
|
+
let { pathExt: e = process.env.PATHEXT || "" } = r, s = e.split(_);
|
|
161
|
+
if (s.indexOf("") !== -1) return true;
|
|
162
|
+
for (let o of s) {
|
|
163
|
+
let c = o.toLowerCase(), n = t.substring(t.length - c.length).toLowerCase();
|
|
164
|
+
if (c && n === c) return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
};
|
|
168
|
+
var m = (t, r, e) => t.isFile() && P(r, e);
|
|
169
|
+
var v = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
|
|
170
|
+
var g = v === "win32" ? a : i;
|
|
171
|
+
var R = g.isexe;
|
|
172
|
+
var U = g.sync;
|
|
173
|
+
|
|
174
|
+
// ../../src/which/src/index.ts
|
|
175
|
+
import { delimiter, join, sep } from "node:path";
|
|
176
|
+
var isWindows = process.platform === "win32";
|
|
177
|
+
var rSlash = sep === "/" ? /\// : /[\\/]/;
|
|
178
|
+
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
179
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
180
|
+
var getPathInfo = (cmd, {
|
|
181
|
+
path: optPath = process.env.PATH,
|
|
182
|
+
pathExt: optPathExt = process.env.PATHEXT,
|
|
183
|
+
delimiter: optDelimiter = delimiter
|
|
184
|
+
}) => {
|
|
185
|
+
const pathEnv = cmd.match(rSlash) ? [""] : [
|
|
186
|
+
// windows always checks the cwd first
|
|
187
|
+
/* c8 ignore next - platform-specific */
|
|
188
|
+
...isWindows ? [process.cwd()] : [],
|
|
189
|
+
...(optPath ?? /* c8 ignore next - very unusual */
|
|
190
|
+
"").split(
|
|
191
|
+
optDelimiter
|
|
192
|
+
)
|
|
193
|
+
];
|
|
194
|
+
if (isWindows) {
|
|
195
|
+
const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
|
|
196
|
+
const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]);
|
|
197
|
+
if (cmd.includes(".") && pathExt[0] !== "") {
|
|
198
|
+
pathExt.unshift("");
|
|
199
|
+
}
|
|
200
|
+
return { pathEnv, pathExt, pathExtExe };
|
|
201
|
+
}
|
|
202
|
+
return { pathEnv, pathExt: [""] };
|
|
203
|
+
};
|
|
204
|
+
var getPathPart = (raw, cmd) => {
|
|
205
|
+
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
206
|
+
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
207
|
+
return prefix + join(pathPart, cmd);
|
|
208
|
+
};
|
|
209
|
+
async function which(cmd, opt = {}) {
|
|
210
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
211
|
+
const found = [];
|
|
212
|
+
for (const envPart of pathEnv) {
|
|
213
|
+
const p = getPathPart(envPart, cmd);
|
|
214
|
+
for (const ext of pathExt) {
|
|
215
|
+
const withExt = p + ext;
|
|
216
|
+
const is = await R(withExt, {
|
|
217
|
+
pathExt: pathExtExe,
|
|
218
|
+
ignoreErrors: true
|
|
219
|
+
});
|
|
220
|
+
if (is) {
|
|
221
|
+
if (!opt.all) {
|
|
222
|
+
return withExt;
|
|
223
|
+
}
|
|
224
|
+
found.push(withExt);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (opt.all && found.length) {
|
|
229
|
+
return found;
|
|
230
|
+
}
|
|
231
|
+
if (opt.nothrow) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
throw getNotFoundError(cmd);
|
|
235
|
+
}
|
|
236
|
+
function whichSync(cmd, opt = {}) {
|
|
237
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
238
|
+
const found = [];
|
|
239
|
+
for (const pathEnvPart of pathEnv) {
|
|
240
|
+
const p = getPathPart(pathEnvPart, cmd);
|
|
241
|
+
for (const ext of pathExt) {
|
|
242
|
+
const withExt = p + ext;
|
|
243
|
+
const is = U(withExt, {
|
|
244
|
+
pathExt: pathExtExe,
|
|
245
|
+
ignoreErrors: true
|
|
246
|
+
});
|
|
247
|
+
if (is) {
|
|
248
|
+
if (!opt.all) {
|
|
249
|
+
return withExt;
|
|
250
|
+
}
|
|
251
|
+
found.push(withExt);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (opt.all && found.length) {
|
|
256
|
+
return found;
|
|
257
|
+
}
|
|
258
|
+
if (opt.nothrow) {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
throw getNotFoundError(cmd);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export {
|
|
265
|
+
promiseSpawn,
|
|
266
|
+
which,
|
|
267
|
+
whichSync
|
|
268
|
+
};
|