This commit is contained in:
2025-08-18 23:06:34 +08:00
parent 0bc04fb659
commit ed18af0cad
1926 changed files with 275098 additions and 0 deletions

14
package/node_modules/read-cmd-shim/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,14 @@
Copyright (c) 2015, Rebecca Turner <me@re-becca.org>
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.

75
package/node_modules/read-cmd-shim/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,75 @@
const fs = require('fs')
const { promisify } = require('util')
const { readFileSync } = fs
const readFile = promisify(fs.readFile)
const extractPath = (path, cmdshimContents) => {
if (/[.]cmd$/.test(path)) {
return extractPathFromCmd(cmdshimContents)
} else if (/[.]ps1$/.test(path)) {
return extractPathFromPowershell(cmdshimContents)
} else {
return extractPathFromCygwin(cmdshimContents)
}
}
const extractPathFromPowershell = cmdshimContents => {
const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+[$]args/)
return matches && matches[1]
}
const extractPathFromCmd = cmdshimContents => {
const matches = cmdshimContents.match(/"%(?:~dp0|dp0%)\\([^"]+?)"\s+%[*]/)
return matches && matches[1]
}
const extractPathFromCygwin = cmdshimContents => {
const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+"[$]@"/)
return matches && matches[1]
}
const wrapError = (thrown, newError) => {
newError.message = thrown.message
newError.code = thrown.code
newError.path = thrown.path
return newError
}
const notaShim = (path, er) => {
if (!er) {
er = new Error()
Error.captureStackTrace(er, notaShim)
}
er.code = 'ENOTASHIM'
er.message = `Can't read shim path from '${path}', ` +
`it doesn't appear to be a cmd-shim`
return er
}
const readCmdShim = path => {
// create a new error to capture the stack trace from this point,
// instead of getting some opaque stack into node's internals
const er = new Error()
Error.captureStackTrace(er, readCmdShim)
return readFile(path).then(contents => {
const destination = extractPath(path, contents.toString())
if (destination) {
return destination
}
throw notaShim(path, er)
}, readFileEr => {
throw wrapError(readFileEr, er)
})
}
const readCmdShimSync = path => {
const contents = readFileSync(path)
const destination = extractPath(path, contents.toString())
if (!destination) {
throw notaShim(path)
}
return destination
}
readCmdShim.sync = readCmdShimSync
module.exports = readCmdShim

47
package/node_modules/read-cmd-shim/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "read-cmd-shim",
"version": "4.0.0",
"description": "Figure out what a cmd-shim is pointing at. This acts as the equivalent of fs.readlink.",
"main": "lib/index.js",
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "4.5.1",
"cmd-shim": "^5.0.0",
"rimraf": "^3.0.0",
"tap": "^16.0.1"
},
"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"
},
"tap": {
"check-coverage": true,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"repository": {
"type": "git",
"url": "https://github.com/npm/read-cmd-shim.git"
},
"license": "ISC",
"homepage": "https://github.com/npm/read-cmd-shim#readme",
"files": [
"bin/",
"lib/"
],
"author": "GitHub Inc.",
"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.5.1"
}
}