| Current Path : /home/emeraadmin/public_html/4d695/ |
| Current File : /home/emeraadmin/public_html/4d695/read-cmd-shim.tar |
package.json 0000644 00000002663 15170143262 0007042 0 ustar 00 {
"_id": "read-cmd-shim@4.0.0",
"_inBundle": true,
"_location": "/npm/read-cmd-shim",
"_phantomChildren": {},
"_requiredBy": [
"/npm/bin-links"
],
"author": {
"name": "GitHub Inc."
},
"bugs": {
"url": "https://github.com/npm/read-cmd-shim/issues"
},
"description": "Figure out what a cmd-shim is pointing at. This acts as the equivalent of fs.readlink.",
"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"
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"files": [
"bin/",
"lib/"
],
"homepage": "https://github.com/npm/read-cmd-shim#readme",
"license": "ISC",
"main": "lib/index.js",
"name": "read-cmd-shim",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/read-cmd-shim.git"
},
"scripts": {
"lint": "eslint \"**/*.js\"",
"lintfix": "npm run lint -- --fix",
"postlint": "template-oss-check",
"posttest": "npm run lint",
"snap": "tap",
"template-oss-apply": "template-oss-apply --force",
"test": "tap"
},
"tap": {
"check-coverage": true,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.5.1"
},
"version": "4.0.0"
}
lib/index.js 0000644 00000004024 15170143262 0006760 0 ustar 00 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
LICENSE 0000644 00000001360 15170143262 0005552 0 ustar 00 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.