| Server IP : 121.121.20.254 / Your IP : 216.73.217.51 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/nodejs/node_modules/npm/node_modules/libnpmexec/lib/ |
Upload File : |
const ciInfo = require('ci-info')
const runScript = require('@npmcli/run-script')
const pkgJson = require('@npmcli/package-json')
const { log, output } = require('proc-log')
const noTTY = require('./no-tty.js')
const isWindowsShell = require('./is-windows.js')
const run = async ({
args,
call,
flatOptions,
locationMsg,
path,
binPaths,
runPath,
scriptShell,
}) => {
// escape executable path
// necessary for preventing bash/cmd keywords from overriding
if (!isWindowsShell) {
if (args.length > 0) {
// single-quote so shell metacharacters in the executable name are taken
// literally; double quotes still expand $(), backticks, $var and "
args[0] = `'${args[0].replace(/'/g, `'\\''`)}'`
}
}
// turn list of args into command string
const script = call || args.shift() || scriptShell
// do the fakey runScript dance
// still should work if no package.json in cwd
const { content: realPkg } = await pkgJson.normalize(path, { steps: [
'binDir',
...pkgJson.normalizeSteps,
] }).catch(() => ({ content: {} }))
const pkg = {
...realPkg,
scripts: {
...(realPkg.scripts || {}),
npx: script,
},
}
if (script === scriptShell) {
if (!noTTY()) {
if (ciInfo.isCI) {
return log.warn('exec', 'Interactive mode disabled in CI environment')
}
const { chalk } = flatOptions
output.standard(`${
chalk.reset('\nEntering npm script environment')
}${
chalk.reset(locationMsg || ` at location:\n${chalk.dim(runPath)}`)
}${
chalk.bold('\nType \'exit\' or ^D when finished\n')
}`)
}
}
return runScript({
...flatOptions,
pkg,
// we always run in cwd, not --prefix
path: runPath,
binPaths,
event: 'npx',
args,
stdio: 'inherit',
scriptShell,
})
}
module.exports = run