Skip to content

Commit

Permalink
deps: which@4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Aug 30, 2023
1 parent b1ad3ad commit 12337cc
Show file tree
Hide file tree
Showing 30 changed files with 1,250 additions and 21 deletions.
12 changes: 12 additions & 0 deletions node_modules/.gitignore
Expand Up @@ -22,15 +22,24 @@
!/@npmcli/disparity-colors
!/@npmcli/fs
!/@npmcli/git
!/@npmcli/git/node_modules/
/@npmcli/git/node_modules/*
!/@npmcli/git/node_modules/which
!/@npmcli/installed-package-contents
!/@npmcli/map-workspaces
!/@npmcli/metavuln-calculator
!/@npmcli/name-from-folder
!/@npmcli/node-gyp
!/@npmcli/package-json
!/@npmcli/promise-spawn
!/@npmcli/promise-spawn/node_modules/
/@npmcli/promise-spawn/node_modules/*
!/@npmcli/promise-spawn/node_modules/which
!/@npmcli/query
!/@npmcli/run-script
!/@npmcli/run-script/node_modules/
/@npmcli/run-script/node_modules/*
!/@npmcli/run-script/node_modules/which
!/@pkgjs/
/@pkgjs/*
!/@pkgjs/parseargs
Expand Down Expand Up @@ -281,6 +290,9 @@
!/walk-up-path
!/wcwidth
!/which
!/which/node_modules/
/which/node_modules/*
!/which/node_modules/isexe
!/wide-align
!/wrap-ansi-cjs
!/wrap-ansi
Expand Down
15 changes: 15 additions & 0 deletions node_modules/@npmcli/git/node_modules/which/LICENSE
@@ -0,0 +1,15 @@
The ISC License

Copyright (c) Isaac Z. Schlueter and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 changes: 52 additions & 0 deletions node_modules/@npmcli/git/node_modules/which/bin/which.js
@@ -0,0 +1,52 @@
#!/usr/bin/env node

const which = require('../lib')
const argv = process.argv.slice(2)

const usage = (err) => {
if (err) {
console.error(`which: ${err}`)
}
console.error('usage: which [-as] program ...')
process.exit(1)
}

if (!argv.length) {
return usage()
}

let dashdash = false
const [commands, flags] = argv.reduce((acc, arg) => {
if (dashdash || arg === '--') {
dashdash = true
return acc
}

if (!/^-/.test(arg)) {
acc[0].push(arg)
return acc
}

for (const flag of arg.slice(1).split('')) {
if (flag === 's') {
acc[1].silent = true
} else if (flag === 'a') {
acc[1].all = true
} else {
usage(`illegal option -- ${flag}`)
}
}

return acc
}, [[], {}])

for (const command of commands) {
try {
const res = which.sync(command, { all: flags.all })
if (!flags.silent) {
console.log([].concat(res).join('\n'))
}
} catch (err) {
process.exitCode = 1
}
}
115 changes: 115 additions & 0 deletions node_modules/@npmcli/git/node_modules/which/lib/index.js
@@ -0,0 +1,115 @@
const isexe = require('isexe')
const { join, delimiter, sep, posix } = require('path')

const isWindows = process.platform === 'win32'

// used to check for slashed in commands passed in. always checks for the posix
// seperator on all platforms, and checks for the current separator when not on
// a posix platform. don't use the isWindows check for this since that is mocked
// in tests but we still need the code to actually work when called. that is also
// why it is ignored from coverage.
/* istanbul ignore next */
const rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? '' : sep}]`.replace(/(\\)/g, '\\$1'))
const rRel = new RegExp(`^\\.${rSlash.source}`)

const getNotFoundError = (cmd) =>
Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })

const getPathInfo = (cmd, {
path: optPath = process.env.PATH,
pathExt: optPathExt = process.env.PATHEXT,
delimiter: optDelimiter = delimiter,
}) => {
// If it has a slash, then we don't bother searching the pathenv.
// just check the file itself, and that's it.
const pathEnv = cmd.match(rSlash) ? [''] : [
// windows always checks the cwd first
...(isWindows ? [process.cwd()] : []),
...(optPath || /* istanbul ignore next: very unusual */ '').split(optDelimiter),
]

if (isWindows) {
const pathExtExe = optPathExt ||
['.EXE', '.CMD', '.BAT', '.COM'].join(optDelimiter)
const pathExt = pathExtExe.split(optDelimiter).reduce((acc, item) => {
acc.push(item)
acc.push(item.toLowerCase())
return acc
}, [])
if (cmd.includes('.') && pathExt[0] !== '') {
pathExt.unshift('')
}
return { pathEnv, pathExt, pathExtExe }
}

return { pathEnv, pathExt: [''] }
}

const getPathPart = (raw, cmd) => {
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : ''
return prefix + join(pathPart, cmd)
}

const which = async (cmd, opt = {}) => {
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
const found = []

for (const envPart of pathEnv) {
const p = getPathPart(envPart, cmd)

for (const ext of pathExt) {
const withExt = p + ext
const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true })
if (is) {
if (!opt.all) {
return withExt
}
found.push(withExt)
}
}
}

if (opt.all && found.length) {
return found
}

if (opt.nothrow) {
return null
}

throw getNotFoundError(cmd)
}

const whichSync = (cmd, opt = {}) => {
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt)
const found = []

for (const pathEnvPart of pathEnv) {
const p = getPathPart(pathEnvPart, cmd)

for (const ext of pathExt) {
const withExt = p + ext
const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true })
if (is) {
if (!opt.all) {
return withExt
}
found.push(withExt)
}
}
}

if (opt.all && found.length) {
return found
}

if (opt.nothrow) {
return null
}

throw getNotFoundError(cmd)
}

module.exports = which
which.sync = whichSync
51 changes: 51 additions & 0 deletions node_modules/@npmcli/git/node_modules/which/package.json
@@ -0,0 +1,51 @@
{
"author": "GitHub Inc.",
"name": "which",
"description": "Like which(1) unix command. Find the first instance of an executable in the PATH.",
"version": "3.0.1",
"repository": {
"type": "git",
"url": "https://github.com/npm/node-which.git"
},
"main": "lib/index.js",
"bin": {
"node-which": "./bin/which.js"
},
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.14.1",
"tap": "^16.3.0"
},
"scripts": {
"test": "tap",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force",
"lintfix": "npm run lint -- --fix",
"snap": "tap",
"posttest": "npm run lint"
},
"files": [
"bin/",
"lib/"
],
"tap": {
"check-coverage": true,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.14.1",
"publish": "true"
}
}
15 changes: 15 additions & 0 deletions node_modules/@npmcli/promise-spawn/node_modules/which/LICENSE
@@ -0,0 +1,15 @@
The ISC License

Copyright (c) Isaac Z. Schlueter and Contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 changes: 52 additions & 0 deletions node_modules/@npmcli/promise-spawn/node_modules/which/bin/which.js
@@ -0,0 +1,52 @@
#!/usr/bin/env node

const which = require('../lib')
const argv = process.argv.slice(2)

const usage = (err) => {
if (err) {
console.error(`which: ${err}`)
}
console.error('usage: which [-as] program ...')
process.exit(1)
}

if (!argv.length) {
return usage()
}

let dashdash = false
const [commands, flags] = argv.reduce((acc, arg) => {
if (dashdash || arg === '--') {
dashdash = true
return acc
}

if (!/^-/.test(arg)) {
acc[0].push(arg)
return acc
}

for (const flag of arg.slice(1).split('')) {
if (flag === 's') {
acc[1].silent = true
} else if (flag === 'a') {
acc[1].all = true
} else {
usage(`illegal option -- ${flag}`)
}
}

return acc
}, [[], {}])

for (const command of commands) {
try {
const res = which.sync(command, { all: flags.all })
if (!flags.silent) {
console.log([].concat(res).join('\n'))
}
} catch (err) {
process.exitCode = 1
}
}

0 comments on commit 12337cc

Please sign in to comment.