@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.
Files changed (51) hide show
  1. package/components/metadata.js +2 -1
  2. package/lib/prepare_security.js +20 -21
  3. package/lib/request.js +1 -1
  4. package/lib/utils.js +4 -2
  5. package/package.json +1 -5
  6. package/node_modules/isexe/LICENSE.md +0 -55
  7. package/node_modules/isexe/README.md +0 -80
  8. package/node_modules/isexe/dist/commonjs/index.d.ts +0 -14
  9. package/node_modules/isexe/dist/commonjs/index.d.ts.map +0 -1
  10. package/node_modules/isexe/dist/commonjs/index.js +0 -56
  11. package/node_modules/isexe/dist/commonjs/index.js.map +0 -1
  12. package/node_modules/isexe/dist/commonjs/index.min.js +0 -2
  13. package/node_modules/isexe/dist/commonjs/index.min.js.map +0 -7
  14. package/node_modules/isexe/dist/commonjs/options.d.ts +0 -32
  15. package/node_modules/isexe/dist/commonjs/options.d.ts.map +0 -1
  16. package/node_modules/isexe/dist/commonjs/options.js +0 -3
  17. package/node_modules/isexe/dist/commonjs/options.js.map +0 -1
  18. package/node_modules/isexe/dist/commonjs/package.json +0 -3
  19. package/node_modules/isexe/dist/commonjs/posix.d.ts +0 -18
  20. package/node_modules/isexe/dist/commonjs/posix.d.ts.map +0 -1
  21. package/node_modules/isexe/dist/commonjs/posix.js +0 -67
  22. package/node_modules/isexe/dist/commonjs/posix.js.map +0 -1
  23. package/node_modules/isexe/dist/commonjs/win32.d.ts +0 -18
  24. package/node_modules/isexe/dist/commonjs/win32.d.ts.map +0 -1
  25. package/node_modules/isexe/dist/commonjs/win32.js +0 -63
  26. package/node_modules/isexe/dist/commonjs/win32.js.map +0 -1
  27. package/node_modules/isexe/dist/esm/index.d.ts +0 -14
  28. package/node_modules/isexe/dist/esm/index.d.ts.map +0 -1
  29. package/node_modules/isexe/dist/esm/index.js +0 -16
  30. package/node_modules/isexe/dist/esm/index.js.map +0 -1
  31. package/node_modules/isexe/dist/esm/index.min.js +0 -2
  32. package/node_modules/isexe/dist/esm/index.min.js.map +0 -7
  33. package/node_modules/isexe/dist/esm/options.d.ts +0 -32
  34. package/node_modules/isexe/dist/esm/options.d.ts.map +0 -1
  35. package/node_modules/isexe/dist/esm/options.js +0 -2
  36. package/node_modules/isexe/dist/esm/options.js.map +0 -1
  37. package/node_modules/isexe/dist/esm/package.json +0 -3
  38. package/node_modules/isexe/dist/esm/posix.d.ts +0 -18
  39. package/node_modules/isexe/dist/esm/posix.d.ts.map +0 -1
  40. package/node_modules/isexe/dist/esm/posix.js +0 -62
  41. package/node_modules/isexe/dist/esm/posix.js.map +0 -1
  42. package/node_modules/isexe/dist/esm/win32.d.ts +0 -18
  43. package/node_modules/isexe/dist/esm/win32.d.ts.map +0 -1
  44. package/node_modules/isexe/dist/esm/win32.js +0 -58
  45. package/node_modules/isexe/dist/esm/win32.js.map +0 -1
  46. package/node_modules/isexe/package.json +0 -78
  47. package/node_modules/which/LICENSE +0 -15
  48. package/node_modules/which/README.md +0 -51
  49. package/node_modules/which/bin/which.js +0 -52
  50. package/node_modules/which/lib/index.js +0 -111
  51. package/node_modules/which/package.json +0 -52
@@ -61,7 +61,8 @@ export function formatMetadataResult({ status, data, metadata, checker }) {
61
61
  owner: data.owner,
62
62
  repo: data.repo,
63
63
  number: data.prid,
64
- url: data.pr.url
64
+ url: data.pr.url,
65
+ labels: data.pr.labels.nodes.map(({ name }) => name)
65
66
  },
66
67
  metadata,
67
68
  reasonCodes,
@@ -2,6 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import auth from './auth.js';
4
4
  import Request from './request.js';
5
+ import { parsePRFromURL } from './links.js';
5
6
  import {
6
7
  NEXT_SECURITY_RELEASE_BRANCH,
7
8
  NEXT_SECURITY_RELEASE_FOLDER,
@@ -196,8 +197,7 @@ export default class PrepareSecurityRelease extends SecurityRelease {
196
197
  await this.closeAndRequestDisclosure(vulnerabilityJSON.reports);
197
198
 
198
199
  this.cli.info('Closing pull requests');
199
- // For now, close the ones with Security Release label
200
- await this.closePRWithLabel('Security Release');
200
+ await this.closePullRequests(vulnerabilityJSON);
201
201
 
202
202
  if (vulnerabilityJSON.buildIssue) {
203
203
  this.cli.info('Commenting on nodejs/build issue');
@@ -637,26 +637,25 @@ export default class PrepareSecurityRelease extends SecurityRelease {
637
637
  this.cli.stopSpinner('Done closing H1 Reports and requesting disclosure');
638
638
  }
639
639
 
640
- async closePRWithLabel(labels) {
641
- if (typeof labels === 'string') {
642
- labels = [labels];
643
- }
644
-
645
- const url = 'https://github.com/nodejs-private/node-private/pull';
640
+ async closePullRequests(vulnerabilityJSON) {
646
641
  this.cli.startSpinner('Closing GitHub Pull Requests...');
647
- // At this point, GitHub does not provide filters through their REST API
648
- const prs = await this.req.getPullRequest(url);
649
- for (const pr of prs) {
650
- if (pr.labels.some((l) => labels.includes(l.name))) {
651
- this.cli.updateSpinner(`Closing Pull Request: ${pr.number}`);
652
- await confirmSecurityStep(
653
- this.cli,
654
- `close GitHub pull request \`nodejs-private/node-private#${pr.number}\``,
655
- 'This closes a pull request labeled for the security release.'
656
- );
657
- await this.req.closePullRequest(pr.number,
658
- { owner: 'nodejs-private', repo: 'node-private' });
659
- }
642
+ const entries = [
643
+ ...vulnerabilityJSON.reports,
644
+ ...Object.values(vulnerabilityJSON.dependencies ?? {})
645
+ ];
646
+ const urls = new Set(entries.flatMap(
647
+ ({ affectedVersions }) => Object.values(affectedVersions)));
648
+
649
+ for (const url of urls) {
650
+ const { owner, repo, prid } = parsePRFromURL(url);
651
+ const name = `${owner}/${repo}#${prid}`;
652
+ this.cli.updateSpinner(`Closing Pull Request: ${name}`);
653
+ await confirmSecurityStep(
654
+ this.cli,
655
+ `close GitHub pull request \`${name}\``,
656
+ 'This closes a pull request listed in vulnerabilities.json.'
657
+ );
658
+ await this.req.closePullRequest(prid, { owner, repo });
660
659
  }
661
660
  this.cli.stopSpinner('Closed GitHub Pull Requests.');
662
661
  }
package/lib/request.js CHANGED
@@ -158,7 +158,7 @@ export default class Request {
158
158
  async closePullRequest(id, { owner, repo }) {
159
159
  const url = `/repos/${owner}/${repo}/pulls/${id}`;
160
160
  const options = {
161
- method: 'POST',
161
+ method: 'PATCH',
162
162
  headers: {
163
163
  'Content-Type': 'application/json'
164
164
  },
package/lib/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { platform } from 'node:os';
2
- import which from 'which';
2
+ import { spawnSync } from 'node:child_process';
3
3
 
4
4
  import { forceRunAsync } from './run.js';
5
5
 
@@ -32,7 +32,9 @@ export function shortSha(sha) {
32
32
  let isGhAvailableCache;
33
33
  export function isGhAvailable() {
34
34
  if (isGhAvailableCache === undefined) {
35
- isGhAvailableCache = which.sync('gh', { nothrow: true }) !== null;
35
+ isGhAvailableCache = spawnSync(
36
+ 'gh', ['--version'], { stdio: 'ignore' }
37
+ ).status === 0;
36
38
  }
37
39
  return isGhAvailableCache;
38
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-core/utils",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "Utilities for Node.js core collaborators",
5
5
  "type": "module",
6
6
  "engines": {
@@ -52,7 +52,6 @@
52
52
  "semver": "^7.7.1",
53
53
  "smol-toml": "^1.7.0",
54
54
  "undici": "^8.3.0",
55
- "which": "^7.0.0",
56
55
  "yargs": "^18.0.0"
57
56
  },
58
57
  "devDependencies": {
@@ -61,9 +60,6 @@
61
60
  "c8": "^12.0.0",
62
61
  "eslint": "^9.39.4",
63
62
  "eslint-plugin-import": "^2.32.0",
64
- "eslint-plugin-n": "^17.24.0",
65
- "eslint-plugin-promise": "^7.3.0",
66
- "globals": "^17.4.0",
67
63
  "neostandard": "^0.13.0",
68
64
  "sinon": "^22.0.0"
69
65
  }
@@ -1,55 +0,0 @@
1
- # Blue Oak Model License
2
-
3
- Version 1.0.0
4
-
5
- ## Purpose
6
-
7
- This license gives everyone as much permission to work with
8
- this software as possible, while protecting contributors
9
- from liability.
10
-
11
- ## Acceptance
12
-
13
- In order to receive this license, you must agree to its
14
- rules. The rules of this license are both obligations
15
- under that agreement and conditions to your license.
16
- You must not do anything with this software that triggers
17
- a rule that you cannot or will not follow.
18
-
19
- ## Copyright
20
-
21
- Each contributor licenses you to do everything with this
22
- software that would otherwise infringe that contributor's
23
- copyright in it.
24
-
25
- ## Notices
26
-
27
- You must ensure that everyone who gets a copy of
28
- any part of this software from you, with or without
29
- changes, also gets the text of this license or a link to
30
- <https://blueoakcouncil.org/license/1.0.0>.
31
-
32
- ## Excuse
33
-
34
- If anyone notifies you in writing that you have not
35
- complied with [Notices](#notices), you can keep your
36
- license by taking all practical steps to comply within 30
37
- days after the notice. If you do not do so, your license
38
- ends immediately.
39
-
40
- ## Patent
41
-
42
- Each contributor licenses you to do everything with this
43
- software that would otherwise infringe any patent claims
44
- they can license or become able to license.
45
-
46
- ## Reliability
47
-
48
- No contributor can revoke this license.
49
-
50
- ## No Liability
51
-
52
- ***As far as the law allows, this software comes as is,
53
- without any warranty or condition, and no contributor
54
- will be liable to anyone for any damages related to this
55
- software or this license, under any kind of legal claim.***
@@ -1,80 +0,0 @@
1
- # isexe
2
-
3
- Minimal module to check if a file is executable, and a normal file.
4
-
5
- Uses `fs.stat` and tests against the `PATHEXT` environment variable on
6
- Windows.
7
-
8
- ## USAGE
9
-
10
- ```js
11
- // default export is a minified version that doesn't need to
12
- // load more than one file. Load the 'isexe/raw' export if
13
- // you want the non-minified version for some reason.
14
- import { isexe, sync } from 'isexe'
15
- // or require() works too
16
- // const { isexe } = require('isexe')
17
- isexe('some-file-name').then(
18
- isExe => {
19
- if (isExe) {
20
- console.error('this thing can be run')
21
- } else {
22
- console.error('cannot be run')
23
- }
24
- },
25
- err => {
26
- console.error('probably file doesnt exist or something')
27
- },
28
- )
29
-
30
- // same thing but synchronous, throws errors
31
- isExe = sync('some-file-name')
32
-
33
- // treat errors as just "not executable"
34
- const isExe = await isexe('maybe-missing-file', { ignoreErrors: true })
35
- const isExe = sync('maybe-missing-file', { ignoreErrors: true })
36
- ```
37
-
38
- ## API
39
-
40
- ### `isexe(path, [options]) => Promise<boolean>`
41
-
42
- Check if the path is executable.
43
-
44
- Will raise whatever errors may be raised by `fs.stat`, unless
45
- `options.ignoreErrors` is set to true.
46
-
47
- ### `sync(path, [options]) => boolean`
48
-
49
- Same as `isexe` but returns the value and throws any errors raised.
50
-
51
- ## Platform Specific Implementations
52
-
53
- If for some reason you want to use the implementation for a
54
- specific platform, you can do that.
55
-
56
- ```js
57
- import { win32, posix } from 'isexe'
58
- win32.isexe(...)
59
- win32.sync(...)
60
- // etc
61
-
62
- // or:
63
- import { isexe, sync } from 'isexe/posix'
64
- ```
65
-
66
- The default exported implementation will be chosen based on
67
- `process.platform`.
68
-
69
- ### Options
70
-
71
- ```ts
72
- import type IsexeOptions from 'isexe'
73
- ```
74
-
75
- - `ignoreErrors` Treat all errors as "no, this is not
76
- executable", but don't raise them.
77
- - `uid` Number to use as the user id on posix
78
- - `gid` Number to use as the group id on posix
79
- - `pathExt` List of path extensions to use instead of `PATHEXT`
80
- environment variable on Windows.
@@ -1,14 +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
- /**
6
- * Determine whether a path is executable on the current platform.
7
- */
8
- export declare const isexe: (path: string, options?: import("./options.js").IsexeOptions) => Promise<boolean>;
9
- /**
10
- * Synchronously determine whether a path is executable on the
11
- * current platform.
12
- */
13
- export declare const sync: (path: string, options?: import("./options.js").IsexeOptions) => boolean;
14
- //# sourceMappingURL=index.d.ts.map
@@ -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,56 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.sync = exports.isexe = exports.posix = exports.win32 = void 0;
40
- const posix = __importStar(require("./posix.js"));
41
- exports.posix = posix;
42
- const win32 = __importStar(require("./win32.js"));
43
- exports.win32 = win32;
44
- __exportStar(require("./options.js"), exports);
45
- const platform = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
46
- const impl = platform === 'win32' ? win32 : posix;
47
- /**
48
- * Determine whether a path is executable on the current platform.
49
- */
50
- exports.isexe = impl.isexe;
51
- /**
52
- * Synchronously determine whether a path is executable on the
53
- * current platform.
54
- */
55
- exports.sync = impl.sync;
56
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAmC;AAGnB,sBAAK;AAFrB,kDAAmC;AAE1B,sBAAK;AADd,+CAA4B;AAG5B,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;AACU,QAAA,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;AAC/B;;;GAGG;AACU,QAAA,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
- "use strict";var a=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var _=a(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});i.sync=i.isexe=void 0;var M=require("node:fs"),x=require("node:fs/promises"),q=async(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return d(await(0,x.stat)(t),e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};i.isexe=q;var m=(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return d((0,M.statSync)(t),e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};i.sync=m;var d=(t,e)=>t.isFile()&&A(t,e),A=(t,e)=>{let r=e.uid??process.getuid?.(),s=e.groups??process.getgroups?.()??[],n=e.gid??process.getgid?.()??s[0];if(r===void 0||n===void 0)throw new Error("cannot get uid or gid");let u=new Set([n,...s]),c=t.mode,S=t.uid,P=t.gid,f=parseInt("100",8),l=parseInt("010",8),j=parseInt("001",8),C=f|l;return!!(c&j||c&l&&u.has(P)||c&f&&S===r||c&C&&r===0)}});var g=a(o=>{"use strict";Object.defineProperty(o,"__esModule",{value:!0});o.sync=o.isexe=void 0;var T=require("node:fs"),I=require("node:fs/promises"),D=require("node:path"),F=async(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return y(await(0,I.stat)(t),t,e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};o.isexe=F;var L=(t,e={})=>{let{ignoreErrors:r=!1}=e;try{return y((0,T.statSync)(t),t,e)}catch(s){let n=s;if(r||n.code==="EACCES")return!1;throw n}};o.sync=L;var B=(t,e)=>{let{pathExt:r=process.env.PATHEXT||""}=e,s=r.split(D.delimiter);if(s.indexOf("")!==-1)return!0;for(let n of s){let u=n.toLowerCase(),c=t.substring(t.length-u.length).toLowerCase();if(u&&c===u)return!0}return!1},y=(t,e,r)=>t.isFile()&&B(e,r)});var p=a(h=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0})});var v=exports&&exports.__createBinding||(Object.create?(function(t,e,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,n)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]})),G=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),w=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var s=[];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(s[s.length]=n);return s},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var s=t(e),n=0;n<s.length;n++)s[n]!=="default"&&v(r,e,s[n]);return G(r,e),r}})(),X=exports&&exports.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&v(e,t,r)};Object.defineProperty(exports,"__esModule",{value:!0});exports.sync=exports.isexe=exports.posix=exports.win32=void 0;var E=w(_());exports.posix=E;var O=w(g());exports.win32=O;X(p(),exports);var H=process.env._ISEXE_TEST_PLATFORM_||process.platform,b=H==="win32"?O:E;exports.isexe=b.isexe;exports.sync=b.sync;
2
- //# sourceMappingURL=index.min.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/posix.ts", "../../src/win32.ts", "options.js", "../../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", "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n//# sourceMappingURL=options.js.map", "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": "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",
6
- "names": ["node_fs_1", "promises_1", "isexe", "path", "options", "ignoreErrors", "checkStat", "e", "er", "exports", "sync", "stat", "checkMode", "myUid", "myGroups", "myGid", "groups", "mod", "uid", "gid", "u", "g", "o", "ug", "node_fs_1", "promises_1", "node_path_1", "isexe", "path", "options", "ignoreErrors", "checkStat", "e", "er", "exports", "sync", "checkPathExt", "pathExt", "peSplit", "pes", "p", "ext", "stat", "require_options", "__commonJSMin", "exports", "posix", "__importStar", "win32", "__exportStar", "platform", "impl"]
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,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=options.js.map
@@ -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,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -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,67 +0,0 @@
1
- "use strict";
2
- /**
3
- * This is the Posix implementation of isexe, which uses the file
4
- * mode and uid/gid values.
5
- *
6
- * @module
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.sync = exports.isexe = void 0;
10
- const node_fs_1 = require("node:fs");
11
- const promises_1 = require("node:fs/promises");
12
- /**
13
- * Determine whether a path is executable according to the mode and
14
- * current (or specified) user and group IDs.
15
- */
16
- const isexe = async (path, options = {}) => {
17
- const { ignoreErrors = false } = options;
18
- try {
19
- return checkStat(await (0, promises_1.stat)(path), options);
20
- }
21
- catch (e) {
22
- const er = e;
23
- if (ignoreErrors || er.code === 'EACCES')
24
- return false;
25
- throw er;
26
- }
27
- };
28
- exports.isexe = isexe;
29
- /**
30
- * Synchronously determine whether a path is executable according to
31
- * the mode and current (or specified) user and group IDs.
32
- */
33
- const sync = (path, options = {}) => {
34
- const { ignoreErrors = false } = options;
35
- try {
36
- return checkStat((0, node_fs_1.statSync)(path), options);
37
- }
38
- catch (e) {
39
- const er = e;
40
- if (ignoreErrors || er.code === 'EACCES')
41
- return false;
42
- throw er;
43
- }
44
- };
45
- exports.sync = sync;
46
- const checkStat = (stat, options) => stat.isFile() && checkMode(stat, options);
47
- const checkMode = (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 === undefined || myGid === undefined) {
52
- throw new Error('cannot get uid or gid');
53
- }
54
- const groups = 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 ||
63
- (mod & g && groups.has(gid)) ||
64
- (mod & u && uid === myUid) ||
65
- (mod & ug && myUid === 0));
66
- };
67
- //# sourceMappingURL=posix.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"posix.js","sourceRoot":"","sources":["../../src/posix.ts"],"names":[],"mappings":"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","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,63 +0,0 @@
1
- "use strict";
2
- /**
3
- * This is the Windows implementation of isexe, which uses the file
4
- * extension and PATHEXT setting.
5
- *
6
- * @module
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.sync = exports.isexe = void 0;
10
- const node_fs_1 = require("node:fs");
11
- const promises_1 = require("node:fs/promises");
12
- const node_path_1 = require("node:path");
13
- /**
14
- * Determine whether a path is executable based on the file extension
15
- * and PATHEXT environment variable (or specified pathExt option)
16
- */
17
- const isexe = async (path, options = {}) => {
18
- const { ignoreErrors = false } = options;
19
- try {
20
- return checkStat(await (0, promises_1.stat)(path), path, options);
21
- }
22
- catch (e) {
23
- const er = e;
24
- if (ignoreErrors || er.code === 'EACCES')
25
- return false;
26
- throw er;
27
- }
28
- };
29
- exports.isexe = isexe;
30
- /**
31
- * Synchronously determine whether a path is executable based on the file
32
- * extension and PATHEXT environment variable (or specified pathExt option)
33
- */
34
- const sync = (path, options = {}) => {
35
- const { ignoreErrors = false } = options;
36
- try {
37
- return checkStat((0, node_fs_1.statSync)(path), path, options);
38
- }
39
- catch (e) {
40
- const er = e;
41
- if (ignoreErrors || er.code === 'EACCES')
42
- return false;
43
- throw er;
44
- }
45
- };
46
- exports.sync = sync;
47
- const checkPathExt = (path, options) => {
48
- const { pathExt = process.env.PATHEXT || '' } = options;
49
- const peSplit = pathExt.split(node_path_1.delimiter);
50
- if (peSplit.indexOf('') !== -1) {
51
- return true;
52
- }
53
- for (const pes of peSplit) {
54
- const p = pes.toLowerCase();
55
- const ext = path.substring(path.length - p.length).toLowerCase();
56
- if (p && ext === p) {
57
- return true;
58
- }
59
- }
60
- return false;
61
- };
62
- const checkStat = (stat, path, options) => stat.isFile() && checkPathExt(path, options);
63
- //# sourceMappingURL=win32.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"win32.js","sourceRoot":"","sources":["../../src/win32.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAAyC;AACzC,+CAAuC;AAEvC,yCAAqC;AAErC;;;GAGG;AACI,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,IAAA,eAAI,EAAC,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,CAAC,CAAA;AAZY,QAAA,KAAK,SAYjB;AAED;;;GAGG;AACI,MAAM,IAAI,GAAG,CAClB,IAAY,EACZ,UAAwB,EAAE,EACjB,EAAE;IACX,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAA,kBAAQ,EAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACjD,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,CAAC,CAAA;AAZY,QAAA,IAAI,QAYhB;AAED,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,OAAqB,EAAE,EAAE;IAC3D,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,GAAG,OAAO,CAAA;IACvD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,qBAAS,CAAC,CAAA;IACxC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;QAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;QAEhE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,CAAC,IAAW,EAAE,IAAY,EAAE,OAAqB,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,14 +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
- /**
6
- * Determine whether a path is executable on the current platform.
7
- */
8
- export declare const isexe: (path: string, options?: import("./options.js").IsexeOptions) => Promise<boolean>;
9
- /**
10
- * Synchronously determine whether a path is executable on the
11
- * current platform.
12
- */
13
- export declare const sync: (path: string, options?: import("./options.js").IsexeOptions) => boolean;
14
- //# sourceMappingURL=index.d.ts.map