@socketsecurity/lib 3.2.6 → 3.2.7

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/constants/node.js +1 -1
  3. package/dist/constants/packages.js +4 -4
  4. package/dist/external/@inquirer/confirm.js +3199 -18
  5. package/dist/external/@inquirer/input.js +3223 -18
  6. package/dist/external/@inquirer/password.js +3331 -18
  7. package/dist/external/@inquirer/search.js +3328 -21
  8. package/dist/external/@inquirer/select.js +3445 -21
  9. package/dist/external/@npmcli/package-json/lib/read-package.js +149 -2
  10. package/dist/external/@npmcli/package-json/lib/sort.js +96 -1
  11. package/dist/external/@npmcli/package-json.js +16758 -13
  12. package/dist/external/@npmcli/promise-spawn.js +480 -1
  13. package/dist/external/@socketregistry/is-unicode-supported.js +42 -1
  14. package/dist/external/@socketregistry/packageurl-js.js +6493 -2
  15. package/dist/external/@socketregistry/yocto-spinner.js +460 -4
  16. package/dist/external/@yarnpkg/extensions.js +1025 -1
  17. package/dist/external/cacache.js +13016 -12
  18. package/dist/external/debug.js +27 -1
  19. package/dist/external/del.js +7088 -2
  20. package/dist/external/fast-glob.js +5721 -2
  21. package/dist/external/fast-sort.js +140 -1
  22. package/dist/external/get-east-asian-width.js +90 -1
  23. package/dist/external/libnpmexec.js +33 -1
  24. package/dist/external/libnpmpack.js +67595 -129
  25. package/dist/external/make-fetch-happen.js +22595 -21
  26. package/dist/external/normalize-package-data.js +4474 -2
  27. package/dist/external/npm-package-arg.js +4511 -2
  28. package/dist/external/pacote.js +50270 -57
  29. package/dist/external/picomatch.js +1520 -1
  30. package/dist/external/semver.js +1930 -1
  31. package/dist/external/spdx-correct.js +1380 -1
  32. package/dist/external/spdx-expression-parse.js +1043 -1
  33. package/dist/external/streaming-iterables.js +1056 -1
  34. package/dist/external/validate-npm-package-name.js +100 -1
  35. package/dist/external/which.js +258 -1
  36. package/dist/external/yargs-parser.js +1075 -1
  37. package/dist/external/yoctocolors-cjs.js +88 -1
  38. package/dist/external/zod.js +15207 -13
  39. package/dist/lifecycle-script-names.js +3 -4
  40. package/dist/maintained-node-versions.js +3 -4
  41. package/dist/package-default-node-range.js +4 -5
  42. package/dist/package-default-socket-categories.js +3 -4
  43. package/dist/package-extensions.js +3 -4
  44. package/dist/utils/get-ipc.js +3 -5
  45. package/package.json +1 -1
@@ -3,4 +3,103 @@
3
3
  * Bundled from validate-npm-package-name
4
4
  * This is a zero-dependency bundle created by esbuild.
5
5
  */
6
- "use strict";var h=Object.defineProperty;var o=(n,t)=>h(n,"name",{value:t,configurable:!0});var f=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var l=f((b,u)=>{"use strict";var{builtinModules:p}=require("module"),d=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$"),g=["node_modules","favicon.ico"];function v(n){var t=[],e=[];if(n===null)return e.push("name cannot be null"),r(t,e);if(n===void 0)return e.push("name cannot be undefined"),r(t,e);if(typeof n!="string")return e.push("name must be a string"),r(t,e);if(n.length||e.push("name length must be greater than zero"),n.startsWith(".")&&e.push("name cannot start with a period"),n.match(/^_/)&&e.push("name cannot start with an underscore"),n.trim()!==n&&e.push("name cannot contain leading or trailing spaces"),g.forEach(function(c){n.toLowerCase()===c&&e.push(c+" is not a valid package name")}),p.includes(n.toLowerCase())&&t.push(n+" is a core module name"),n.length>214&&t.push("name can no longer contain more than 214 characters"),n.toLowerCase()!==n&&t.push("name can no longer contain capital letters"),/[~'!()*]/.test(n.split("/").slice(-1)[0])&&t.push(`name can no longer contain special characters ("~'!()*")`),encodeURIComponent(n)!==n){var i=n.match(d);if(i){var s=i[1],a=i[2];if(a.startsWith(".")&&e.push("name cannot start with a period"),encodeURIComponent(s)===s&&encodeURIComponent(a)===a)return r(t,e)}e.push("name can only contain URL-friendly characters")}return r(t,e)}o(v,"validate");var r=o(function(n,t){var e={validForNewPackages:t.length===0&&n.length===0,validForOldPackages:t.length===0,warnings:n,errors:t};return e.warnings.length||delete e.warnings,e.errors.length||delete e.errors,e},"done");u.exports=v});module.exports=l();
6
+ "use strict";
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+
14
+ // node_modules/.pnpm/validate-npm-package-name@6.0.2/node_modules/validate-npm-package-name/lib/index.js
15
+ var require_lib = __commonJS({
16
+ "node_modules/.pnpm/validate-npm-package-name@6.0.2/node_modules/validate-npm-package-name/lib/index.js"(exports2, module2) {
17
+ "use strict";
18
+ var { builtinModules: builtins } = require("module");
19
+ var scopedPackagePattern = new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");
20
+ var exclusionList = [
21
+ "node_modules",
22
+ "favicon.ico"
23
+ ];
24
+ function validate(name) {
25
+ var warnings = [];
26
+ var errors = [];
27
+ if (name === null) {
28
+ errors.push("name cannot be null");
29
+ return done(warnings, errors);
30
+ }
31
+ if (name === void 0) {
32
+ errors.push("name cannot be undefined");
33
+ return done(warnings, errors);
34
+ }
35
+ if (typeof name !== "string") {
36
+ errors.push("name must be a string");
37
+ return done(warnings, errors);
38
+ }
39
+ if (!name.length) {
40
+ errors.push("name length must be greater than zero");
41
+ }
42
+ if (name.startsWith(".")) {
43
+ errors.push("name cannot start with a period");
44
+ }
45
+ if (name.match(/^_/)) {
46
+ errors.push("name cannot start with an underscore");
47
+ }
48
+ if (name.trim() !== name) {
49
+ errors.push("name cannot contain leading or trailing spaces");
50
+ }
51
+ exclusionList.forEach(function(excludedName) {
52
+ if (name.toLowerCase() === excludedName) {
53
+ errors.push(excludedName + " is not a valid package name");
54
+ }
55
+ });
56
+ if (builtins.includes(name.toLowerCase())) {
57
+ warnings.push(name + " is a core module name");
58
+ }
59
+ if (name.length > 214) {
60
+ warnings.push("name can no longer contain more than 214 characters");
61
+ }
62
+ if (name.toLowerCase() !== name) {
63
+ warnings.push("name can no longer contain capital letters");
64
+ }
65
+ if (/[~'!()*]/.test(name.split("/").slice(-1)[0])) {
66
+ warnings.push(`name can no longer contain special characters ("~'!()*")`);
67
+ }
68
+ if (encodeURIComponent(name) !== name) {
69
+ var nameMatch = name.match(scopedPackagePattern);
70
+ if (nameMatch) {
71
+ var user = nameMatch[1];
72
+ var pkg = nameMatch[2];
73
+ if (pkg.startsWith(".")) {
74
+ errors.push("name cannot start with a period");
75
+ }
76
+ if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) {
77
+ return done(warnings, errors);
78
+ }
79
+ }
80
+ errors.push("name can only contain URL-friendly characters");
81
+ }
82
+ return done(warnings, errors);
83
+ }
84
+ __name(validate, "validate");
85
+ var done = /* @__PURE__ */ __name(function(warnings, errors) {
86
+ var result = {
87
+ validForNewPackages: errors.length === 0 && warnings.length === 0,
88
+ validForOldPackages: errors.length === 0,
89
+ warnings,
90
+ errors
91
+ };
92
+ if (!result.warnings.length) {
93
+ delete result.warnings;
94
+ }
95
+ if (!result.errors.length) {
96
+ delete result.errors;
97
+ }
98
+ return result;
99
+ }, "done");
100
+ module2.exports = validate;
101
+ }
102
+ });
103
+
104
+ // src/external/validate-npm-package-name.js
105
+ module.exports = require_lib();
@@ -3,4 +3,261 @@
3
3
  * Bundled from which
4
4
  * This is a zero-dependency bundle created by esbuild.
5
5
  */
6
- "use strict";var N=Object.defineProperty;var c=(e,t)=>N(e,"name",{value:t,configurable:!0});var E=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var y=E(l=>{"use strict";Object.defineProperty(l,"__esModule",{value:!0});l.sync=l.isexe=void 0;var D=require("fs"),G=require("fs/promises"),U=c(async(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return g(await(0,G.stat)(e),t)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}},"isexe");l.isexe=U;var W=c((e,t={})=>{let{ignoreErrors:r=!1}=t;try{return g((0,D.statSync)(e),t)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}},"sync");l.sync=W;var g=c((e,t)=>e.isFile()&&z(e,t),"checkStat"),z=c((e,t)=>{let r=t.uid??process.getuid?.(),s=t.groups??process.getgroups?.()??[],n=t.gid??process.getgid?.()??s[0];if(r===void 0||n===void 0)throw new Error("cannot get uid or gid");let i=new Set([n,...s]),u=e.mode,f=e.uid,p=e.gid,a=parseInt("100",8),d=parseInt("010",8),B=parseInt("001",8),H=a|d;return!!(u&B||u&d&&i.has(p)||u&a&&f===r||u&H&&r===0)},"checkMode")});var x=E(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.sync=h.isexe=void 0;var J=require("fs"),K=require("fs/promises"),Q=c(async(e,t={})=>{let{ignoreErrors:r=!1}=t;try{return _(await(0,K.stat)(e),e,t)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}},"isexe");h.isexe=Q;var V=c((e,t={})=>{let{ignoreErrors:r=!1}=t;try{return _((0,J.statSync)(e),e,t)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}},"sync");h.sync=V;var Y=c((e,t)=>{let{pathExt:r=process.env.PATHEXT||""}=t,s=r.split(";");if(s.indexOf("")!==-1)return!0;for(let n=0;n<s.length;n++){let i=s[n].toLowerCase(),u=e.substring(e.length-i.length).toLowerCase();if(i&&u===i)return!0}return!1},"checkPathExt"),_=c((e,t,r)=>e.isFile()&&Y(t,r),"checkStat")});var v=E(w=>{"use strict";Object.defineProperty(w,"__esModule",{value:!0})});var C=E(o=>{"use strict";var P=o&&o.__createBinding||(Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:c(function(){return t[r]},"get")}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]})),Z=o&&o.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),O=o&&o.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&P(t,e,r);return Z(t,e),t},m=o&&o.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&P(t,e,r)};Object.defineProperty(o,"__esModule",{value:!0});o.sync=o.isexe=o.posix=o.win32=void 0;var S=O(y());o.posix=S;var b=O(x());o.win32=b;m(v(),o);var k=process.env._ISEXE_TEST_PLATFORM_||process.platform,j=k==="win32"?b:S;o.isexe=j.isexe;o.sync=j.sync});var X=E((Ee,R)=>{var{isexe:ee,sync:te}=C(),{join:re,delimiter:ne,sep:M,posix:q}=require("path"),T=process.platform==="win32",A=new RegExp(`[${q.sep}${M===q.sep?"":M}]`.replace(/(\\)/g,"\\$1")),se=new RegExp(`^\\.${A.source}`),$=c(e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),"getNotFoundError"),I=c((e,{path:t=process.env.PATH,pathExt:r=process.env.PATHEXT,delimiter:s=ne})=>{let n=e.match(A)?[""]:[...T?[process.cwd()]:[],...(t||"").split(s)];if(T){let i=r||[".EXE",".CMD",".BAT",".COM"].join(s),u=i.split(s).flatMap(f=>[f,f.toLowerCase()]);return e.includes(".")&&u[0]!==""&&u.unshift(""),{pathEnv:n,pathExt:u,pathExtExe:i}}return{pathEnv:n,pathExt:[""]}},"getPathInfo"),F=c((e,t)=>{let r=/^".*"$/.test(e)?e.slice(1,-1):e;return(!r&&se.test(t)?t.slice(0,2):"")+re(r,t)},"getPathPart"),L=c(async(e,t={})=>{let{pathEnv:r,pathExt:s,pathExtExe:n}=I(e,t),i=[];for(let u of r){let f=F(u,e);for(let p of s){let a=f+p;if(await ee(a,{pathExt:n,ignoreErrors:!0})){if(!t.all)return a;i.push(a)}}}if(t.all&&i.length)return i;if(t.nothrow)return null;throw $(e)},"which"),oe=c((e,t={})=>{let{pathEnv:r,pathExt:s,pathExtExe:n}=I(e,t),i=[];for(let u of r){let f=F(u,e);for(let p of s){let a=f+p;if(te(a,{pathExt:n,ignoreErrors:!0})){if(!t.all)return a;i.push(a)}}}if(t.all&&i.length)return i;if(t.nothrow)return null;throw $(e)},"whichSync");R.exports=L;L.sync=oe});module.exports=X();
6
+ "use strict";
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropNames = Object.getOwnPropertyNames;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+
14
+ // node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/posix.js
15
+ var require_posix = __commonJS({
16
+ "node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/posix.js"(exports2) {
17
+ "use strict";
18
+ Object.defineProperty(exports2, "__esModule", { value: true });
19
+ exports2.sync = exports2.isexe = void 0;
20
+ var fs_1 = require("fs");
21
+ var promises_1 = require("fs/promises");
22
+ var isexe = /* @__PURE__ */ __name(async (path, options = {}) => {
23
+ const { ignoreErrors = false } = options;
24
+ try {
25
+ return checkStat(await (0, promises_1.stat)(path), options);
26
+ } catch (e) {
27
+ const er = e;
28
+ if (ignoreErrors || er.code === "EACCES")
29
+ return false;
30
+ throw er;
31
+ }
32
+ }, "isexe");
33
+ exports2.isexe = isexe;
34
+ var sync = /* @__PURE__ */ __name((path, options = {}) => {
35
+ const { ignoreErrors = false } = options;
36
+ try {
37
+ return checkStat((0, fs_1.statSync)(path), options);
38
+ } catch (e) {
39
+ const er = e;
40
+ if (ignoreErrors || er.code === "EACCES")
41
+ return false;
42
+ throw er;
43
+ }
44
+ }, "sync");
45
+ exports2.sync = sync;
46
+ var checkStat = /* @__PURE__ */ __name((stat, options) => stat.isFile() && checkMode(stat, options), "checkStat");
47
+ var checkMode = /* @__PURE__ */ __name((stat, options) => {
48
+ const myUid = options.uid ?? process.getuid?.();
49
+ const myGroups = options.groups ?? process.getgroups?.() ?? [];
50
+ const myGid = options.gid ?? process.getgid?.() ?? myGroups[0];
51
+ if (myUid === void 0 || myGid === void 0) {
52
+ throw new Error("cannot get uid or gid");
53
+ }
54
+ const groups = /* @__PURE__ */ new Set([myGid, ...myGroups]);
55
+ const mod = stat.mode;
56
+ const uid = stat.uid;
57
+ const gid = stat.gid;
58
+ const u = parseInt("100", 8);
59
+ const g = parseInt("010", 8);
60
+ const o = parseInt("001", 8);
61
+ const ug = u | g;
62
+ return !!(mod & o || mod & g && groups.has(gid) || mod & u && uid === myUid || mod & ug && myUid === 0);
63
+ }, "checkMode");
64
+ }
65
+ });
66
+
67
+ // node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/win32.js
68
+ var require_win32 = __commonJS({
69
+ "node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/win32.js"(exports2) {
70
+ "use strict";
71
+ Object.defineProperty(exports2, "__esModule", { value: true });
72
+ exports2.sync = exports2.isexe = void 0;
73
+ var fs_1 = require("fs");
74
+ var promises_1 = require("fs/promises");
75
+ var isexe = /* @__PURE__ */ __name(async (path, options = {}) => {
76
+ const { ignoreErrors = false } = options;
77
+ try {
78
+ return checkStat(await (0, promises_1.stat)(path), path, options);
79
+ } catch (e) {
80
+ const er = e;
81
+ if (ignoreErrors || er.code === "EACCES")
82
+ return false;
83
+ throw er;
84
+ }
85
+ }, "isexe");
86
+ exports2.isexe = isexe;
87
+ var sync = /* @__PURE__ */ __name((path, options = {}) => {
88
+ const { ignoreErrors = false } = options;
89
+ try {
90
+ return checkStat((0, fs_1.statSync)(path), path, options);
91
+ } catch (e) {
92
+ const er = e;
93
+ if (ignoreErrors || er.code === "EACCES")
94
+ return false;
95
+ throw er;
96
+ }
97
+ }, "sync");
98
+ exports2.sync = sync;
99
+ var checkPathExt = /* @__PURE__ */ __name((path, options) => {
100
+ const { pathExt = process.env.PATHEXT || "" } = options;
101
+ const peSplit = pathExt.split(";");
102
+ if (peSplit.indexOf("") !== -1) {
103
+ return true;
104
+ }
105
+ for (let i = 0; i < peSplit.length; i++) {
106
+ const p = peSplit[i].toLowerCase();
107
+ const ext = path.substring(path.length - p.length).toLowerCase();
108
+ if (p && ext === p) {
109
+ return true;
110
+ }
111
+ }
112
+ return false;
113
+ }, "checkPathExt");
114
+ var checkStat = /* @__PURE__ */ __name((stat, path, options) => stat.isFile() && checkPathExt(path, options), "checkStat");
115
+ }
116
+ });
117
+
118
+ // node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/options.js
119
+ var require_options = __commonJS({
120
+ "node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/options.js"(exports2) {
121
+ "use strict";
122
+ Object.defineProperty(exports2, "__esModule", { value: true });
123
+ }
124
+ });
125
+
126
+ // node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/index.js
127
+ var require_cjs = __commonJS({
128
+ "node_modules/.pnpm/isexe@3.1.1/node_modules/isexe/dist/cjs/index.js"(exports2) {
129
+ "use strict";
130
+ var __createBinding = exports2 && exports2.__createBinding || (Object.create ? (function(o, m, k, k2) {
131
+ if (k2 === void 0) k2 = k;
132
+ var desc = Object.getOwnPropertyDescriptor(m, k);
133
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
134
+ desc = { enumerable: true, get: /* @__PURE__ */ __name(function() {
135
+ return m[k];
136
+ }, "get") };
137
+ }
138
+ Object.defineProperty(o, k2, desc);
139
+ }) : (function(o, m, k, k2) {
140
+ if (k2 === void 0) k2 = k;
141
+ o[k2] = m[k];
142
+ }));
143
+ var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? (function(o, v) {
144
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
145
+ }) : function(o, v) {
146
+ o["default"] = v;
147
+ });
148
+ var __importStar = exports2 && exports2.__importStar || function(mod) {
149
+ if (mod && mod.__esModule) return mod;
150
+ var result = {};
151
+ if (mod != null) {
152
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
153
+ }
154
+ __setModuleDefault(result, mod);
155
+ return result;
156
+ };
157
+ var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
158
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
159
+ };
160
+ Object.defineProperty(exports2, "__esModule", { value: true });
161
+ exports2.sync = exports2.isexe = exports2.posix = exports2.win32 = void 0;
162
+ var posix = __importStar(require_posix());
163
+ exports2.posix = posix;
164
+ var win32 = __importStar(require_win32());
165
+ exports2.win32 = win32;
166
+ __exportStar(require_options(), exports2);
167
+ var platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
168
+ var impl = platform === "win32" ? win32 : posix;
169
+ exports2.isexe = impl.isexe;
170
+ exports2.sync = impl.sync;
171
+ }
172
+ });
173
+
174
+ // node_modules/.pnpm/which@5.0.0/node_modules/which/lib/index.js
175
+ var require_lib = __commonJS({
176
+ "node_modules/.pnpm/which@5.0.0/node_modules/which/lib/index.js"(exports2, module2) {
177
+ var { isexe, sync: isexeSync } = require_cjs();
178
+ var { join, delimiter, sep, posix } = require("path");
179
+ var isWindows = process.platform === "win32";
180
+ var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
181
+ var rRel = new RegExp(`^\\.${rSlash.source}`);
182
+ var getNotFoundError = /* @__PURE__ */ __name((cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" }), "getNotFoundError");
183
+ var getPathInfo = /* @__PURE__ */ __name((cmd, {
184
+ path: optPath = process.env.PATH,
185
+ pathExt: optPathExt = process.env.PATHEXT,
186
+ delimiter: optDelimiter = delimiter
187
+ }) => {
188
+ const pathEnv = cmd.match(rSlash) ? [""] : [
189
+ // windows always checks the cwd first
190
+ ...isWindows ? [process.cwd()] : [],
191
+ ...(optPath || /* istanbul ignore next: very unusual */
192
+ "").split(optDelimiter)
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
+ }, "getPathInfo");
204
+ var getPathPart = /* @__PURE__ */ __name((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
+ }, "getPathPart");
209
+ var which = /* @__PURE__ */ __name(async (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 isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
217
+ if (is) {
218
+ if (!opt.all) {
219
+ return withExt;
220
+ }
221
+ found.push(withExt);
222
+ }
223
+ }
224
+ }
225
+ if (opt.all && found.length) {
226
+ return found;
227
+ }
228
+ if (opt.nothrow) {
229
+ return null;
230
+ }
231
+ throw getNotFoundError(cmd);
232
+ }, "which");
233
+ var whichSync = /* @__PURE__ */ __name((cmd, opt = {}) => {
234
+ const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
235
+ const found = [];
236
+ for (const pathEnvPart of pathEnv) {
237
+ const p = getPathPart(pathEnvPart, cmd);
238
+ for (const ext of pathExt) {
239
+ const withExt = p + ext;
240
+ const is = isexeSync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
241
+ if (is) {
242
+ if (!opt.all) {
243
+ return withExt;
244
+ }
245
+ found.push(withExt);
246
+ }
247
+ }
248
+ }
249
+ if (opt.all && found.length) {
250
+ return found;
251
+ }
252
+ if (opt.nothrow) {
253
+ return null;
254
+ }
255
+ throw getNotFoundError(cmd);
256
+ }, "whichSync");
257
+ module2.exports = which;
258
+ which.sync = whichSync;
259
+ }
260
+ });
261
+
262
+ // src/external/which.js
263
+ module.exports = require_lib();