Skip to content

Commit 4811a86

Browse files
committed
deps: @npmcli/run-script@10.0.3
1 parent 6cb77df commit 4811a86

File tree

118 files changed

+45844
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+45844
-45
lines changed

DEPENDENCIES.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ graph LR;
269269
cacache-->npmcli-fs["@npmcli/fs"];
270270
cacache-->p-map;
271271
cacache-->ssri;
272-
cacache-->tar;
273272
cacache-->unique-filename;
274273
cidr-regex-->ip-regex;
275274
cli-columns-->string-width;

node_modules/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
!/@npmcli/run-script/node_modules/@npmcli/
4040
/@npmcli/run-script/node_modules/@npmcli/*
4141
!/@npmcli/run-script/node_modules/@npmcli/promise-spawn
42+
!/@npmcli/run-script/node_modules/@npmcli/promise-spawn/node_modules/
43+
/@npmcli/run-script/node_modules/@npmcli/promise-spawn/node_modules/*
44+
!/@npmcli/run-script/node_modules/@npmcli/promise-spawn/node_modules/which
45+
!/@npmcli/run-script/node_modules/node-gyp
46+
!/@npmcli/run-script/node_modules/which
4247
!/@pkgjs/
4348
/@pkgjs/*
4449
!/@pkgjs/parseargs
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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": "5.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": "^3.1.1"
17+
},
18+
"devDependencies": {
19+
"@npmcli/eslint-config": "^5.0.0",
20+
"@npmcli/template-oss": "4.23.3",
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": "^18.17.0 || >=20.5.0"
46+
},
47+
"templateOSS": {
48+
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
49+
"version": "4.23.3",
50+
"publish": "true"
51+
}
52+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "12.1.0"
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Code of Conduct
2+
3+
* [Node.js Code of Conduct](https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md)
4+
* [Node.js Moderation Policy](https://github.com/nodejs/admin/blob/master/Moderation-Policy.md)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Contributing to node-gyp
2+
3+
## Code of Conduct
4+
5+
Please read the
6+
[Code of Conduct](https://github.com/nodejs/admin/blob/main/CODE_OF_CONDUCT.md)
7+
which explains the minimum behavior expectations for node-gyp contributors.
8+
9+
<a id="developers-certificate-of-origin"></a>
10+
## Developer's Certificate of Origin 1.1
11+
12+
By making a contribution to this project, I certify that:
13+
14+
* (a) The contribution was created in whole or in part by me and I
15+
have the right to submit it under the open source license
16+
indicated in the file; or
17+
18+
* (b) The contribution is based upon previous work that, to the best
19+
of my knowledge, is covered under an appropriate open source
20+
license and I have the right under that license to submit that
21+
work with modifications, whether created in whole or in part
22+
by me, under the same open source license (unless I am
23+
permitted to submit under a different license), as indicated
24+
in the file; or
25+
26+
* (c) The contribution was provided directly to me by some other
27+
person who certified (a), (b) or (c) and I have not modified
28+
it.
29+
30+
* (d) I understand and agree that this project and the contribution
31+
are public and that a record of the contribution (including all
32+
personal information I submit with it, including my sign-off) is
33+
maintained indefinitely and may be redistributed consistent with
34+
this project or the open source license(s) involved.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net>
4+
5+
Permission is hereby granted, free of charge, to any person
6+
obtaining a copy of this software and associated documentation
7+
files (the "Software"), to deal in the Software without
8+
restriction, including without limitation the rights to use,
9+
copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following
12+
conditions:
13+
14+
The above copyright notice and this permission notice shall be
15+
included in all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24+
OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)