@node-core/utils 7.1.0 → 7.2.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/components/metadata.js +2 -1
- package/lib/prepare_security.js +20 -21
- package/lib/request.js +1 -1
- package/lib/utils.js +4 -2
- package/package.json +1 -5
- package/node_modules/isexe/LICENSE.md +0 -55
- package/node_modules/isexe/README.md +0 -80
- package/node_modules/isexe/dist/commonjs/index.d.ts +0 -14
- package/node_modules/isexe/dist/commonjs/index.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/index.js +0 -56
- package/node_modules/isexe/dist/commonjs/index.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/index.min.js +0 -2
- package/node_modules/isexe/dist/commonjs/index.min.js.map +0 -7
- package/node_modules/isexe/dist/commonjs/options.d.ts +0 -32
- package/node_modules/isexe/dist/commonjs/options.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/options.js +0 -3
- package/node_modules/isexe/dist/commonjs/options.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/package.json +0 -3
- package/node_modules/isexe/dist/commonjs/posix.d.ts +0 -18
- package/node_modules/isexe/dist/commonjs/posix.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/posix.js +0 -67
- package/node_modules/isexe/dist/commonjs/posix.js.map +0 -1
- package/node_modules/isexe/dist/commonjs/win32.d.ts +0 -18
- package/node_modules/isexe/dist/commonjs/win32.d.ts.map +0 -1
- package/node_modules/isexe/dist/commonjs/win32.js +0 -63
- package/node_modules/isexe/dist/commonjs/win32.js.map +0 -1
- package/node_modules/isexe/dist/esm/index.d.ts +0 -14
- package/node_modules/isexe/dist/esm/index.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/index.js +0 -16
- package/node_modules/isexe/dist/esm/index.js.map +0 -1
- package/node_modules/isexe/dist/esm/index.min.js +0 -2
- package/node_modules/isexe/dist/esm/index.min.js.map +0 -7
- package/node_modules/isexe/dist/esm/options.d.ts +0 -32
- package/node_modules/isexe/dist/esm/options.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/options.js +0 -2
- package/node_modules/isexe/dist/esm/options.js.map +0 -1
- package/node_modules/isexe/dist/esm/package.json +0 -3
- package/node_modules/isexe/dist/esm/posix.d.ts +0 -18
- package/node_modules/isexe/dist/esm/posix.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/posix.js +0 -62
- package/node_modules/isexe/dist/esm/posix.js.map +0 -1
- package/node_modules/isexe/dist/esm/win32.d.ts +0 -18
- package/node_modules/isexe/dist/esm/win32.d.ts.map +0 -1
- package/node_modules/isexe/dist/esm/win32.js +0 -58
- package/node_modules/isexe/dist/esm/win32.js.map +0 -1
- package/node_modules/isexe/package.json +0 -78
- package/node_modules/which/LICENSE +0 -15
- package/node_modules/which/README.md +0 -51
- package/node_modules/which/bin/which.js +0 -52
- package/node_modules/which/lib/index.js +0 -111
- package/node_modules/which/package.json +0 -52
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAKvB;;GAEG;AACH,eAAO,MAAM,KAAK,mFAAa,CAAA;AAC/B;;;GAGG;AACH,eAAO,MAAM,IAAI,0EAAY,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as posix from './posix.js';
|
|
2
|
-
import * as win32 from './win32.js';
|
|
3
|
-
export * from './options.js';
|
|
4
|
-
export { win32, posix };
|
|
5
|
-
const platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
|
|
6
|
-
const impl = platform === 'win32' ? win32 : posix;
|
|
7
|
-
/**
|
|
8
|
-
* Determine whether a path is executable on the current platform.
|
|
9
|
-
*/
|
|
10
|
-
export const isexe = impl.isexe;
|
|
11
|
-
/**
|
|
12
|
-
* Synchronously determine whether a path is executable on the
|
|
13
|
-
* current platform.
|
|
14
|
-
*/
|
|
15
|
-
export const sync = impl.sync;
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAEvB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,OAAO,CAAC,QAAQ,CAAA;AACtE,MAAM,IAAI,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;AAC/B;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA","sourcesContent":["import * as posix from './posix.js'\nimport * as win32 from './win32.js'\nexport * from './options.js'\nexport { win32, posix }\n\nconst platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform\nconst impl = platform === 'win32' ? win32 : posix\n\n/**\n * Determine whether a path is executable on the current platform.\n */\nexport const isexe = impl.isexe\n/**\n * Synchronously determine whether a path is executable on the\n * current platform.\n */\nexport const sync = impl.sync\n"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var y=Object.defineProperty;var u=(t,r)=>{for(var e in r)y(t,e,{get:r[e],enumerable:!0})};var i={};u(i,{isexe:()=>C,sync:()=>A});import{statSync as w}from"node:fs";import{stat as S}from"node:fs/promises";var C=async(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return d(await S(t),r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},A=(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return d(w(t),r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},d=(t,r)=>t.isFile()&&T(t,r),T=(t,r)=>{let e=r.uid??process.getuid?.(),s=r.groups??process.getgroups?.()??[],o=r.gid??process.getgid?.()??s[0];if(e===void 0||o===void 0)throw new Error("cannot get uid or gid");let c=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;return!!(n&x||n&p&&c.has(E)||n&f&&l===e||n&h&&e===0)};var a={};u(a,{isexe:()=>F,sync:()=>L});import{statSync as k}from"node:fs";import{stat as I}from"node:fs/promises";import{delimiter as _}from"node:path";var F=async(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return m(await I(t),t,r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},L=(t,r={})=>{let{ignoreErrors:e=!1}=r;try{return m(k(t),t,r)}catch(s){let o=s;if(e||o.code==="EACCES")return!1;throw o}},P=(t,r)=>{let{pathExt:e=process.env.PATHEXT||""}=r,s=e.split(_);if(s.indexOf("")!==-1)return!0;for(let o of s){let c=o.toLowerCase(),n=t.substring(t.length-c.length).toLowerCase();if(c&&n===c)return!0}return!1},m=(t,r,e)=>t.isFile()&&P(r,e);var v=process.env._ISEXE_TEST_PLATFORM_||process.platform,g=v==="win32"?a:i,R=g.isexe,U=g.sync;export{R as isexe,i as posix,U as sync,a as win32};
|
|
2
|
-
//# sourceMappingURL=index.min.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/posix.ts", "../../src/win32.ts", "../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * This is the Posix implementation of isexe, which uses the file\n * mode and uid/gid values.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\n\n/**\n * Determine whether a path is executable according to the mode and\n * current (or specified) user and group IDs.\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable according to\n * the mode and current (or specified) user and group IDs.\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkStat = (stat: Stats, options: IsexeOptions) =>\n stat.isFile() && checkMode(stat, options)\n\nconst checkMode = (stat: Stats, options: IsexeOptions) => {\n const myUid = options.uid ?? process.getuid?.()\n const myGroups = options.groups ?? process.getgroups?.() ?? []\n const myGid = options.gid ?? process.getgid?.() ?? myGroups[0]\n if (myUid === undefined || myGid === undefined) {\n throw new Error('cannot get uid or gid')\n }\n\n const groups = new Set([myGid, ...myGroups])\n\n const mod = stat.mode\n const uid = stat.uid\n const gid = stat.gid\n\n const u = parseInt('100', 8)\n const g = parseInt('010', 8)\n const o = parseInt('001', 8)\n const ug = u | g\n\n return !!(\n mod & o ||\n (mod & g && groups.has(gid)) ||\n (mod & u && uid === myUid) ||\n (mod & ug && myUid === 0)\n )\n}\n", "/**\n * This is the Windows implementation of isexe, which uses the file\n * extension and PATHEXT setting.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\nimport { delimiter } from 'node:path'\n\n/**\n * Determine whether a path is executable based on the file extension\n * and PATHEXT environment variable (or specified pathExt option)\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable based on the file\n * extension and PATHEXT environment variable (or specified pathExt option)\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkPathExt = (path: string, options: IsexeOptions) => {\n const { pathExt = process.env.PATHEXT || '' } = options\n const peSplit = pathExt.split(delimiter)\n if (peSplit.indexOf('') !== -1) {\n return true\n }\n\n for (const pes of peSplit) {\n const p = pes.toLowerCase()\n const ext = path.substring(path.length - p.length).toLowerCase()\n\n if (p && ext === p) {\n return true\n }\n }\n return false\n}\n\nconst checkStat = (stat: Stats, path: string, options: IsexeOptions) =>\n stat.isFile() && checkPathExt(path, options)\n", "import * as posix from './posix.js'\nimport * as win32 from './win32.js'\nexport * from './options.js'\nexport { win32, posix }\n\nconst platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform\nconst impl = platform === 'win32' ? win32 : posix\n\n/**\n * Determine whether a path is executable on the current platform.\n */\nexport const isexe = impl.isexe\n/**\n * Synchronously determine whether a path is executable on the\n * current platform.\n */\nexport const sync = impl.sync\n"],
|
|
5
|
-
"mappings": "0FAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,WAAAE,EAAA,SAAAC,IAOA,OAAgB,YAAAC,MAAgB,UAChC,OAAS,QAAAC,MAAY,mBAOd,IAAMH,EAAQ,MACnBI,EACAC,EAAwB,CAAA,IACJ,CACpB,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAU,MAAMJ,EAAKC,CAAI,EAAGC,CAAO,CAC5C,OAASG,EAAG,CACV,IAAMC,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ACJ,CACpB,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAU,MAAML,EAAKE,CAAI,EAAGA,EAAMC,CAAO,CAClD,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAMaT,EAAO,CAClBI,EACAC,EAAwB,CAAA,IACb,CACX,GAAM,CAAE,aAAAC,EAAe,EAAK,EAAKD,EACjC,GAAI,CACF,OAAOE,EAAUN,EAASG,CAAI,EAAGA,EAAMC,CAAO,CAChD,OAASG,EAAG,CACV,IAAMC,EAAKD,EACX,GAAIF,GAAgBG,EAAG,OAAS,SAAU,MAAO,GACjD,MAAMA,CACR,CACF,EAEMC,EAAe,CAACN,EAAcC,IAAyB,CAC3D,GAAM,CAAE,QAAAM,EAAU,QAAQ,IAAI,SAAW,EAAE,EAAKN,EAC1CO,EAAUD,EAAQ,MAAMR,CAAS,EACvC,GAAIS,EAAQ,QAAQ,EAAE,IAAM,GAC1B,MAAO,GAGT,QAAWC,KAAOD,EAAS,CACzB,IAAME,EAAID,EAAI,YAAW,EACnBE,EAAMX,EAAK,UAAUA,EAAK,OAASU,EAAE,MAAM,EAAE,YAAW,EAE9D,GAAIA,GAAKC,IAAQD,EACf,MAAO,EAEX,CACA,MAAO,EACT,EAEMP,EAAY,CAACL,EAAaE,EAAcC,IAC5CH,EAAK,OAAM,GAAMQ,EAAaN,EAAMC,CAAO,EC9D7C,IAAMW,EAAW,QAAQ,IAAI,uBAAyB,QAAQ,SACxDC,EAAOD,IAAa,QAAUE,EAAQC,EAK/BC,EAAQH,EAAK,MAKbI,EAAOJ,EAAK",
|
|
6
|
-
"names": ["posix_exports", "__export", "isexe", "sync", "statSync", "stat", "path", "options", "ignoreErrors", "checkStat", "e", "er", "checkMode", "myUid", "myGroups", "myGid", "groups", "mod", "uid", "gid", "u", "g", "o", "ug", "win32_exports", "__export", "isexe", "sync", "statSync", "stat", "delimiter", "path", "options", "ignoreErrors", "checkStat", "e", "er", "checkPathExt", "pathExt", "peSplit", "pes", "p", "ext", "platform", "impl", "win32_exports", "posix_exports", "isexe", "sync"]
|
|
7
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface IsexeOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Ignore errors arising from attempting to get file access status
|
|
4
|
-
* Note that EACCES is always ignored, because that just means
|
|
5
|
-
* it's not executable. If this is not set, then attempting to check
|
|
6
|
-
* the executable-ness of a nonexistent file will raise ENOENT, for
|
|
7
|
-
* example.
|
|
8
|
-
*/
|
|
9
|
-
ignoreErrors?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* effective uid when checking executable mode flags on posix
|
|
12
|
-
* Defaults to process.getuid()
|
|
13
|
-
*/
|
|
14
|
-
uid?: number;
|
|
15
|
-
/**
|
|
16
|
-
* effective gid when checking executable mode flags on posix
|
|
17
|
-
* Defaults to process.getgid()
|
|
18
|
-
*/
|
|
19
|
-
gid?: number;
|
|
20
|
-
/**
|
|
21
|
-
* effective group ID list to use when checking executable mode flags
|
|
22
|
-
* on posix
|
|
23
|
-
* Defaults to process.getgroups()
|
|
24
|
-
*/
|
|
25
|
-
groups?: number[];
|
|
26
|
-
/**
|
|
27
|
-
* The ;-delimited path extension list for win32 implementation.
|
|
28
|
-
* Defaults to process.env.PATHEXT
|
|
29
|
-
*/
|
|
30
|
-
pathExt?: string;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IAEtB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"","sourcesContent":["export interface IsexeOptions {\n /**\n * Ignore errors arising from attempting to get file access status\n * Note that EACCES is always ignored, because that just means\n * it's not executable. If this is not set, then attempting to check\n * the executable-ness of a nonexistent file will raise ENOENT, for\n * example.\n */\n ignoreErrors?: boolean\n\n /**\n * effective uid when checking executable mode flags on posix\n * Defaults to process.getuid()\n */\n uid?: number\n\n /**\n * effective gid when checking executable mode flags on posix\n * Defaults to process.getgid()\n */\n gid?: number\n\n /**\n * effective group ID list to use when checking executable mode flags\n * on posix\n * Defaults to process.getgroups()\n */\n groups?: number[]\n\n /**\n * The ;-delimited path extension list for win32 implementation.\n * Defaults to process.env.PATHEXT\n */\n pathExt?: string\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the Posix implementation of isexe, which uses the file
|
|
3
|
-
* mode and uid/gid values.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { IsexeOptions } from './options.js';
|
|
8
|
-
/**
|
|
9
|
-
* Determine whether a path is executable according to the mode and
|
|
10
|
-
* current (or specified) user and group IDs.
|
|
11
|
-
*/
|
|
12
|
-
export declare const isexe: (path: string, options?: IsexeOptions) => Promise<boolean>;
|
|
13
|
-
/**
|
|
14
|
-
* Synchronously determine whether a path is executable according to
|
|
15
|
-
* the mode and current (or specified) user and group IDs.
|
|
16
|
-
*/
|
|
17
|
-
export declare const sync: (path: string, options?: IsexeOptions) => boolean;
|
|
18
|
-
//# sourceMappingURL=posix.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"posix.d.ts","sourceRoot":"","sources":["../../src/posix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C;;;GAGG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OAAO,CAAC,OAAO,CASjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OASF,CAAA"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the Posix implementation of isexe, which uses the file
|
|
3
|
-
* mode and uid/gid values.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { statSync } from 'node:fs';
|
|
8
|
-
import { stat } from 'node:fs/promises';
|
|
9
|
-
/**
|
|
10
|
-
* Determine whether a path is executable according to the mode and
|
|
11
|
-
* current (or specified) user and group IDs.
|
|
12
|
-
*/
|
|
13
|
-
export const isexe = async (path, options = {}) => {
|
|
14
|
-
const { ignoreErrors = false } = options;
|
|
15
|
-
try {
|
|
16
|
-
return checkStat(await stat(path), options);
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
const er = e;
|
|
20
|
-
if (ignoreErrors || er.code === 'EACCES')
|
|
21
|
-
return false;
|
|
22
|
-
throw er;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Synchronously determine whether a path is executable according to
|
|
27
|
-
* the mode and current (or specified) user and group IDs.
|
|
28
|
-
*/
|
|
29
|
-
export const sync = (path, options = {}) => {
|
|
30
|
-
const { ignoreErrors = false } = options;
|
|
31
|
-
try {
|
|
32
|
-
return checkStat(statSync(path), options);
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
const er = e;
|
|
36
|
-
if (ignoreErrors || er.code === 'EACCES')
|
|
37
|
-
return false;
|
|
38
|
-
throw er;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const checkStat = (stat, options) => stat.isFile() && checkMode(stat, options);
|
|
42
|
-
const checkMode = (stat, options) => {
|
|
43
|
-
const myUid = options.uid ?? process.getuid?.();
|
|
44
|
-
const myGroups = options.groups ?? process.getgroups?.() ?? [];
|
|
45
|
-
const myGid = options.gid ?? process.getgid?.() ?? myGroups[0];
|
|
46
|
-
if (myUid === undefined || myGid === undefined) {
|
|
47
|
-
throw new Error('cannot get uid or gid');
|
|
48
|
-
}
|
|
49
|
-
const groups = new Set([myGid, ...myGroups]);
|
|
50
|
-
const mod = stat.mode;
|
|
51
|
-
const uid = stat.uid;
|
|
52
|
-
const gid = stat.gid;
|
|
53
|
-
const u = parseInt('100', 8);
|
|
54
|
-
const g = parseInt('010', 8);
|
|
55
|
-
const o = parseInt('001', 8);
|
|
56
|
-
const ug = u | g;
|
|
57
|
-
return !!(mod & o ||
|
|
58
|
-
(mod & g && groups.has(gid)) ||
|
|
59
|
-
(mod & u && uid === myUid) ||
|
|
60
|
-
(mod & ug && myUid === 0));
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=posix.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"posix.js","sourceRoot":"","sources":["../../src/posix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGvC;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,IAAY,EACZ,UAAwB,EAAE,EACR,EAAE;IACpB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;IAC7C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,GAAG,CAA0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M,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAA;IAE5C,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAA;IACrB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IACpB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;IAEpB,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC5B,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC5B,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC5B,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAA;IAEhB,OAAO,CAAC,CAAC,CACP,GAAG,GAAG,CAAC;QACP,CAAC,GAAG,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC,GAAG,GAAG,CAAC,IAAI,GAAG,KAAK,KAAK,CAAC;QAC1B,CAAC,GAAG,GAAG,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAC1B,CAAA;AACH,CAAC,CAAA","sourcesContent":["/**\n * This is the Posix implementation of isexe, which uses the file\n * mode and uid/gid values.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\n\n/**\n * Determine whether a path is executable according to the mode and\n * current (or specified) user and group IDs.\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable according to\n * the mode and current (or specified) user and group IDs.\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkStat = (stat: Stats, options: IsexeOptions) =>\n stat.isFile() && checkMode(stat, options)\n\nconst checkMode = (stat: Stats, options: IsexeOptions) => {\n const myUid = options.uid ?? process.getuid?.()\n const myGroups = options.groups ?? process.getgroups?.() ?? []\n const myGid = options.gid ?? process.getgid?.() ?? myGroups[0]\n if (myUid === undefined || myGid === undefined) {\n throw new Error('cannot get uid or gid')\n }\n\n const groups = new Set([myGid, ...myGroups])\n\n const mod = stat.mode\n const uid = stat.uid\n const gid = stat.gid\n\n const u = parseInt('100', 8)\n const g = parseInt('010', 8)\n const o = parseInt('001', 8)\n const ug = u | g\n\n return !!(\n mod & o ||\n (mod & g && groups.has(gid)) ||\n (mod & u && uid === myUid) ||\n (mod & ug && myUid === 0)\n )\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the Windows implementation of isexe, which uses the file
|
|
3
|
-
* extension and PATHEXT setting.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { IsexeOptions } from './options.js';
|
|
8
|
-
/**
|
|
9
|
-
* Determine whether a path is executable based on the file extension
|
|
10
|
-
* and PATHEXT environment variable (or specified pathExt option)
|
|
11
|
-
*/
|
|
12
|
-
export declare const isexe: (path: string, options?: IsexeOptions) => Promise<boolean>;
|
|
13
|
-
/**
|
|
14
|
-
* Synchronously determine whether a path is executable based on the file
|
|
15
|
-
* extension and PATHEXT environment variable (or specified pathExt option)
|
|
16
|
-
*/
|
|
17
|
-
export declare const sync: (path: string, options?: IsexeOptions) => boolean;
|
|
18
|
-
//# sourceMappingURL=win32.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"win32.d.ts","sourceRoot":"","sources":["../../src/win32.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C;;;GAGG;AACH,eAAO,MAAM,KAAK,GAChB,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OAAO,CAAC,OAAO,CASjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,GACf,MAAM,MAAM,EACZ,UAAS,YAAiB,KACzB,OASF,CAAA"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is the Windows implementation of isexe, which uses the file
|
|
3
|
-
* extension and PATHEXT setting.
|
|
4
|
-
*
|
|
5
|
-
* @module
|
|
6
|
-
*/
|
|
7
|
-
import { statSync } from 'node:fs';
|
|
8
|
-
import { stat } from 'node:fs/promises';
|
|
9
|
-
import { delimiter } from 'node:path';
|
|
10
|
-
/**
|
|
11
|
-
* Determine whether a path is executable based on the file extension
|
|
12
|
-
* and PATHEXT environment variable (or specified pathExt option)
|
|
13
|
-
*/
|
|
14
|
-
export const isexe = async (path, options = {}) => {
|
|
15
|
-
const { ignoreErrors = false } = options;
|
|
16
|
-
try {
|
|
17
|
-
return checkStat(await stat(path), path, options);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
const er = e;
|
|
21
|
-
if (ignoreErrors || er.code === 'EACCES')
|
|
22
|
-
return false;
|
|
23
|
-
throw er;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Synchronously determine whether a path is executable based on the file
|
|
28
|
-
* extension and PATHEXT environment variable (or specified pathExt option)
|
|
29
|
-
*/
|
|
30
|
-
export const sync = (path, options = {}) => {
|
|
31
|
-
const { ignoreErrors = false } = options;
|
|
32
|
-
try {
|
|
33
|
-
return checkStat(statSync(path), path, options);
|
|
34
|
-
}
|
|
35
|
-
catch (e) {
|
|
36
|
-
const er = e;
|
|
37
|
-
if (ignoreErrors || er.code === 'EACCES')
|
|
38
|
-
return false;
|
|
39
|
-
throw er;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const checkPathExt = (path, options) => {
|
|
43
|
-
const { pathExt = process.env.PATHEXT || '' } = options;
|
|
44
|
-
const peSplit = pathExt.split(delimiter);
|
|
45
|
-
if (peSplit.indexOf('') !== -1) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
for (const pes of peSplit) {
|
|
49
|
-
const p = pes.toLowerCase();
|
|
50
|
-
const ext = path.substring(path.length - p.length).toLowerCase();
|
|
51
|
-
if (p && ext === p) {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return false;
|
|
56
|
-
};
|
|
57
|
-
const checkStat = (stat, path, options) => stat.isFile() && checkPathExt(path, options);
|
|
58
|
-
//# sourceMappingURL=win32.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"win32.js","sourceRoot":"","sources":["../../src/win32.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAS,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,IAAY,EACZ,UAAwB,EAAE,EACR,EAAE;IACpB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,GAAG,CAA0B,CAAA;QACrC,IAAI,YAAY,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAA;QACtD,MAAM,EAAE,CAAA;IACV,CAAC;AACH,C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qB,EAAE,EAAE,CACrE,IAAI,CAAC,MAAM,EAAE,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA","sourcesContent":["/**\n * This is the Windows implementation of isexe, which uses the file\n * extension and PATHEXT setting.\n *\n * @module\n */\n\nimport { Stats, statSync } from 'node:fs'\nimport { stat } from 'node:fs/promises'\nimport { IsexeOptions } from './options.js'\nimport { delimiter } from 'node:path'\n\n/**\n * Determine whether a path is executable based on the file extension\n * and PATHEXT environment variable (or specified pathExt option)\n */\nexport const isexe = async (\n path: string,\n options: IsexeOptions = {},\n): Promise<boolean> => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(await stat(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\n/**\n * Synchronously determine whether a path is executable based on the file\n * extension and PATHEXT environment variable (or specified pathExt option)\n */\nexport const sync = (\n path: string,\n options: IsexeOptions = {},\n): boolean => {\n const { ignoreErrors = false } = options\n try {\n return checkStat(statSync(path), path, options)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (ignoreErrors || er.code === 'EACCES') return false\n throw er\n }\n}\n\nconst checkPathExt = (path: string, options: IsexeOptions) => {\n const { pathExt = process.env.PATHEXT || '' } = options\n const peSplit = pathExt.split(delimiter)\n if (peSplit.indexOf('') !== -1) {\n return true\n }\n\n for (const pes of peSplit) {\n const p = pes.toLowerCase()\n const ext = path.substring(path.length - p.length).toLowerCase()\n\n if (p && ext === p) {\n return true\n }\n }\n return false\n}\n\nconst checkStat = (stat: Stats, path: string, options: IsexeOptions) =>\n stat.isFile() && checkPathExt(path, options)\n"]}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "isexe",
|
|
3
|
-
"version": "4.0.0",
|
|
4
|
-
"description": "Minimal module to check if a file is executable.",
|
|
5
|
-
"main": "./dist/commonjs/index.min.js",
|
|
6
|
-
"module": "./dist/esm/index.min.js",
|
|
7
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
|
-
"tshy": {
|
|
12
|
-
"selfLink": false,
|
|
13
|
-
"exports": {
|
|
14
|
-
"./raw": "./src/index.ts",
|
|
15
|
-
"./package.json": "./package.json",
|
|
16
|
-
".": {
|
|
17
|
-
"import": {
|
|
18
|
-
"types": "./dist/esm/index.d.ts",
|
|
19
|
-
"default": "./dist/esm/index.min.js"
|
|
20
|
-
},
|
|
21
|
-
"require": {
|
|
22
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
23
|
-
"default": "./dist/commonjs/index.min.js"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"exports": {
|
|
29
|
-
"./raw": {
|
|
30
|
-
"import": {
|
|
31
|
-
"types": "./dist/esm/index.d.ts",
|
|
32
|
-
"default": "./dist/esm/index.js"
|
|
33
|
-
},
|
|
34
|
-
"require": {
|
|
35
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
36
|
-
"default": "./dist/commonjs/index.js"
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"./package.json": "./package.json",
|
|
40
|
-
".": {
|
|
41
|
-
"import": {
|
|
42
|
-
"types": "./dist/esm/index.d.ts",
|
|
43
|
-
"default": "./dist/esm/index.min.js"
|
|
44
|
-
},
|
|
45
|
-
"require": {
|
|
46
|
-
"types": "./dist/commonjs/index.d.ts",
|
|
47
|
-
"default": "./dist/commonjs/index.min.js"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@types/node": "^25.2.1",
|
|
53
|
-
"esbuild": "^0.27.3",
|
|
54
|
-
"prettier": "^3.8.1",
|
|
55
|
-
"tap": "^21.5.1",
|
|
56
|
-
"tshy": "^3.1.3",
|
|
57
|
-
"typedoc": "^0.28.16"
|
|
58
|
-
},
|
|
59
|
-
"scripts": {
|
|
60
|
-
"preversion": "npm test",
|
|
61
|
-
"postversion": "npm publish",
|
|
62
|
-
"prepublishOnly": "git push origin --follow-tags",
|
|
63
|
-
"prepare": "tshy && bash build.sh",
|
|
64
|
-
"pretest": "npm run prepare",
|
|
65
|
-
"presnap": "npm run prepare",
|
|
66
|
-
"test": "tap",
|
|
67
|
-
"snap": "tap",
|
|
68
|
-
"format": "prettier --write .",
|
|
69
|
-
"typedoc": "typedoc"
|
|
70
|
-
},
|
|
71
|
-
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
72
|
-
"license": "BlueOak-1.0.0",
|
|
73
|
-
"repository": "https://github.com/isaacs/isexe",
|
|
74
|
-
"engines": {
|
|
75
|
-
"node": ">=20"
|
|
76
|
-
},
|
|
77
|
-
"type": "module"
|
|
78
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
The ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
-
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# which
|
|
2
|
-
|
|
3
|
-
Like the unix `which` utility.
|
|
4
|
-
|
|
5
|
-
Finds the first instance of a specified executable in the PATH
|
|
6
|
-
environment variable. Does not cache the results, so `hash -r` is not
|
|
7
|
-
needed when the PATH changes.
|
|
8
|
-
|
|
9
|
-
## USAGE
|
|
10
|
-
|
|
11
|
-
```javascript
|
|
12
|
-
const which = require('which')
|
|
13
|
-
|
|
14
|
-
// async usage
|
|
15
|
-
// rejects if not found
|
|
16
|
-
const resolved = await which('node')
|
|
17
|
-
|
|
18
|
-
// if nothrow option is used, returns null if not found
|
|
19
|
-
const resolvedOrNull = await which('node', { nothrow: true })
|
|
20
|
-
|
|
21
|
-
// sync usage
|
|
22
|
-
// throws if not found
|
|
23
|
-
const resolved = which.sync('node')
|
|
24
|
-
|
|
25
|
-
// if nothrow option is used, returns null if not found
|
|
26
|
-
const resolvedOrNull = which.sync('node', { nothrow: true })
|
|
27
|
-
|
|
28
|
-
// Pass options to override the PATH and PATHEXT environment vars.
|
|
29
|
-
await which('node', { path: someOtherPath, pathExt: somePathExt })
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## CLI USAGE
|
|
33
|
-
|
|
34
|
-
Just like the BSD `which(1)` binary but using `node-which`.
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
usage: node-which [-as] program ...
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
You can learn more about why the binary is `node-which` and not `which`
|
|
41
|
-
[here](https://github.com/npm/node-which/pull/67)
|
|
42
|
-
|
|
43
|
-
## OPTIONS
|
|
44
|
-
|
|
45
|
-
You may pass an options object as the second argument.
|
|
46
|
-
|
|
47
|
-
- `path`: Use instead of the `PATH` environment variable.
|
|
48
|
-
- `pathExt`: Use instead of the `PATHEXT` environment variable.
|
|
49
|
-
- `all`: Return all matches, instead of just the first one. Note that
|
|
50
|
-
this means the function returns an array of strings instead of a
|
|
51
|
-
single string.
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const which = require('../lib')
|
|
4
|
-
const argv = process.argv.slice(2)
|
|
5
|
-
|
|
6
|
-
const usage = (err) => {
|
|
7
|
-
if (err) {
|
|
8
|
-
console.error(`which: ${err}`)
|
|
9
|
-
}
|
|
10
|
-
console.error('usage: which [-as] program ...')
|
|
11
|
-
process.exit(1)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (!argv.length) {
|
|
15
|
-
return usage()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let dashdash = false
|
|
19
|
-
const [commands, flags] = argv.reduce((acc, arg) => {
|
|
20
|
-
if (dashdash || arg === '--') {
|
|
21
|
-
dashdash = true
|
|
22
|
-
return acc
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!/^-/.test(arg)) {
|
|
26
|
-
acc[0].push(arg)
|
|
27
|
-
return acc
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
for (const flag of arg.slice(1).split('')) {
|
|
31
|
-
if (flag === 's') {
|
|
32
|
-
acc[1].silent = true
|
|
33
|
-
} else if (flag === 'a') {
|
|
34
|
-
acc[1].all = true
|
|
35
|
-
} else {
|
|
36
|
-
usage(`illegal option -- ${flag}`)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return acc
|
|
41
|
-
}, [[], {}])
|
|
42
|
-
|
|
43
|
-
for (const command of commands) {
|
|
44
|
-
try {
|
|
45
|
-
const res = which.sync(command, { all: flags.all })
|
|
46
|
-
if (!flags.silent) {
|
|
47
|
-
console.log([].concat(res).join('\n'))
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
process.exitCode = 1
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
const { isexe, sync: isexeSync } = require('isexe')
|
|
2
|
-
const { join, delimiter, sep, posix } = require('path')
|
|
3
|
-
|
|
4
|
-
const isWindows = process.platform === 'win32'
|
|
5
|
-
|
|
6
|
-
// used to check for slashed in commands passed in. always checks for the posix
|
|
7
|
-
// seperator on all platforms, and checks for the current separator when not on
|
|
8
|
-
// a posix platform. don't use the isWindows check for this since that is mocked
|
|
9
|
-
// in tests but we still need the code to actually work when called. that is also
|
|
10
|
-
// why it is ignored from coverage.
|
|
11
|
-
/* istanbul ignore next */
|
|
12
|
-
const rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? '' : sep}]`.replace(/(\\)/g, '\\$1'))
|
|
13
|
-
const rRel = new RegExp(`^\\.${rSlash.source}`)
|
|
14
|
-
|
|
15
|
-
const getNotFoundError = (cmd) =>
|
|
16
|
-
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
|
|
17
|
-
|
|
18
|
-
const getPathInfo = (cmd, {
|
|
19
|
-
path: optPath = process.env.PATH,
|
|
20
|
-
pathExt: optPathExt = process.env.PATHEXT,
|
|
21
|
-
delimiter: optDelimiter = delimiter,
|
|
22
|
-
}) => {
|
|
23
|
-
// If it has a slash, then we don't bother searching the pathenv.
|
|
24
|
-
// just check the file itself, and that's it.
|
|
25
|
-
const pathEnv = cmd.match(rSlash) ? [''] : [
|
|
26
|
-
// windows always checks the cwd first
|
|
27
|
-
...(isWindows ? [process.cwd()] : []),
|
|
28
|
-
...(optPath || /* istanbul ignore next: very unusual */ '').split(optDelimiter),
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
if (isWindows) {
|
|
32
|
-
const pathExtExe = optPathExt ||
|
|
33
|
-
['.EXE', '.CMD', '.BAT', '.COM'].join(optDelimiter)
|
|
34
|
-
const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()])
|
|
35
|
-
if (cmd.includes('.') && pathExt[0] !== '') {
|
|
36
|
-
pathExt.unshift('')
|
|
37
|
-
}
|
|
38
|
-
return { pathEnv, pathExt, pathExtExe }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return { pathEnv, pathExt: [''] }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const getPathPart = (raw, cmd) => {
|
|
45
|
-
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw
|
|
46
|
-
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : ''
|
|
47
|
-
return prefix + join(pathPart, cmd)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const which = async (cmd, opt = {}) => {
|
|
51
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
52
|
-
const found = []
|
|
53
|
-
|
|
54
|
-
for (const envPart of pathEnv) {
|
|
55
|
-
const p = getPathPart(envPart, cmd)
|
|
56
|
-
|
|
57
|
-
for (const ext of pathExt) {
|
|
58
|
-
const withExt = p + ext
|
|
59
|
-
const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true })
|
|
60
|
-
if (is) {
|
|
61
|
-
if (!opt.all) {
|
|
62
|
-
return withExt
|
|
63
|
-
}
|
|
64
|
-
found.push(withExt)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (opt.all && found.length) {
|
|
70
|
-
return found
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (opt.nothrow) {
|
|
74
|
-
return null
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
throw getNotFoundError(cmd)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const whichSync = (cmd, opt = {}) => {
|
|
81
|
-
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
|
|
82
|
-
const found = []
|
|
83
|
-
|
|
84
|
-
for (const pathEnvPart of pathEnv) {
|
|
85
|
-
const p = getPathPart(pathEnvPart, cmd)
|
|
86
|
-
|
|
87
|
-
for (const ext of pathExt) {
|
|
88
|
-
const withExt = p + ext
|
|
89
|
-
const is = isexeSync(withExt, { pathExt: pathExtExe, ignoreErrors: true })
|
|
90
|
-
if (is) {
|
|
91
|
-
if (!opt.all) {
|
|
92
|
-
return withExt
|
|
93
|
-
}
|
|
94
|
-
found.push(withExt)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (opt.all && found.length) {
|
|
100
|
-
return found
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (opt.nothrow) {
|
|
104
|
-
return null
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
throw getNotFoundError(cmd)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
module.exports = which
|
|
111
|
-
which.sync = whichSync
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"author": "GitHub Inc.",
|
|
3
|
-
"name": "which",
|
|
4
|
-
"description": "Like which(1) unix command. Find the first instance of an executable in the PATH.",
|
|
5
|
-
"version": "7.0.0",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/npm/node-which.git"
|
|
9
|
-
},
|
|
10
|
-
"main": "lib/index.js",
|
|
11
|
-
"bin": {
|
|
12
|
-
"node-which": "./bin/which.js"
|
|
13
|
-
},
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"isexe": "^4.0.0"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@npmcli/eslint-config": "^6.0.0",
|
|
20
|
-
"@npmcli/template-oss": "5.0.0",
|
|
21
|
-
"tap": "^16.3.0"
|
|
22
|
-
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"test": "tap",
|
|
25
|
-
"lint": "npm run eslint",
|
|
26
|
-
"postlint": "template-oss-check",
|
|
27
|
-
"template-oss-apply": "template-oss-apply --force",
|
|
28
|
-
"lintfix": "npm run eslint -- --fix",
|
|
29
|
-
"snap": "tap",
|
|
30
|
-
"posttest": "npm run lint",
|
|
31
|
-
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
|
|
32
|
-
},
|
|
33
|
-
"files": [
|
|
34
|
-
"bin/",
|
|
35
|
-
"lib/"
|
|
36
|
-
],
|
|
37
|
-
"tap": {
|
|
38
|
-
"check-coverage": true,
|
|
39
|
-
"nyc-arg": [
|
|
40
|
-
"--exclude",
|
|
41
|
-
"tap-snapshots/**"
|
|
42
|
-
]
|
|
43
|
-
},
|
|
44
|
-
"engines": {
|
|
45
|
-
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
46
|
-
},
|
|
47
|
-
"templateOSS": {
|
|
48
|
-
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
49
|
-
"version": "5.0.0",
|
|
50
|
-
"publish": "true"
|
|
51
|
-
}
|
|
52
|
-
}
|