/
home
/
techb158
/
.nvm
/
versions
/
node
/
v16.20.2
/
lib
/
node_modules
/
npm
/
lib
/
commands
/
/home/techb158/.nvm/versions/node/v16.20.2/lib/node_modules/npm/lib/commands
mkdir
upload
Name
Size
Mode
Actions
access.js
5585
0644
edit
dl
rm
adduser.js
2253
0644
edit
dl
rm
audit.js
12234
0644
edit
dl
rm
bin.js
729
0644
edit
dl
rm
birthday.js
508
0644
edit
dl
rm
bugs.js
815
0644
edit
dl
rm
cache.js
7247
0644
edit
dl
rm
ci.js
3715
0644
edit
dl
rm
completion.js
9124
0644
edit
dl
rm
config.js
8308
0644
edit
dl
rm
dedupe.js
1405
0644
edit
dl
rm
deprecate.js
2109
0644
edit
dl
rm
diff.js
8291
0644
edit
dl
rm
dist-tag.js
5604
0644
edit
dl
rm
docs.js
447
0644
edit
dl
rm
doctor.js
9446
0644
edit
dl
rm
edit.js
2047
0644
edit
dl
rm
exec.js
2499
0644
edit
dl
rm
explain.js
3639
0644
edit
dl
rm
explore.js
2387
0644
edit
dl
rm
find-dupes.js
602
0644
edit
dl
rm
fund.js
6524
0644
edit
dl
rm
get.js
524
0644
edit
dl
rm
help-search.js
5755
0644
edit
dl
rm
help.js
4637
0644
edit
dl
rm
hook.js
4027
0644
edit
dl
rm
init.js
6972
0644
edit
dl
rm
install-ci-test.js
377
0644
edit
dl
rm
install-test.js
374
0644
edit
dl
rm
install.js
5236
0644
edit
dl
rm
link.js
5141
0644
edit
dl
rm
ll.js
234
0644
edit
dl
rm
logout.js
1377
0644
edit
dl
rm
ls.js
17351
0644
edit
dl
rm
org.js
4305
0644
edit
dl
rm
outdated.js
9050
0644
edit
dl
rm
owner.js
6018
0644
edit
dl
rm
pack.js
2419
0644
edit
dl
rm
ping.js
874
0644
edit
dl
rm
pkg.js
3554
0644
edit
dl
rm
prefix.js
343
0644
edit
dl
rm
profile.js
11525
0644
edit
dl
rm
prune.js
779
0644
edit
dl
rm
publish.js
6481
0644
edit
dl
rm
query.js
2873
0644
edit
dl
rm
rebuild.js
2214
0644
edit
dl
rm
repo.js
1272
0644
edit
dl
rm
restart.js
351
0644
edit
dl
rm
root.js
298
0644
edit
dl
rm
run-script.js
7067
0644
edit
dl
rm
search.js
2781
0644
edit
dl
rm
set-script.js
2698
0644
edit
dl
rm
set.js
572
0644
edit
dl
rm
shrinkwrap.js
2705
0644
edit
dl
rm
star.js
1911
0644
edit
dl
rm
stars.js
1052
0644
edit
dl
rm
start.js
341
0644
edit
dl
rm
stop.js
336
0644
edit
dl
rm
team.js
4545
0644
edit
dl
rm
test.js
336
0644
edit
dl
rm
token.js
6954
0644
edit
dl
rm
uninstall.js
1552
0644
edit
dl
rm
unpublish.js
4617
0644
edit
dl
rm
unstar.js
182
0644
edit
dl
rm
update.js
1738
0644
edit
dl
rm
version.js
3690
0644
edit
dl
rm
view.js
14723
0644
edit
dl
rm
whoami.js
514
0644
edit
dl
rm
Edit:
/home/techb158/.nvm/versions/node/v16.20.2/lib/node_modules/npm/lib/commands/run-script.js
(7067B)
const { resolve } = require('path') const chalk = require('chalk') const runScript = require('@npmcli/run-script') const { isServerPackage } = runScript const rpj = require('read-package-json-fast') const log = require('../utils/log-shim.js') const didYouMean = require('../utils/did-you-mean.js') const { isWindowsShell } = require('../utils/is-windows.js') const cmdList = [ 'publish', 'install', 'uninstall', 'test', 'stop', 'start', 'restart', 'version', ].reduce((l, p) => l.concat(['pre' + p, p, 'post' + p]), []) const nocolor = { reset: s => s, bold: s => s, dim: s => s, blue: s => s, green: s => s, } const BaseCommand = require('../base-command.js') class RunScript extends BaseCommand { static description = 'Run arbitrary package scripts' static params = [ 'workspace', 'workspaces', 'include-workspace-root', 'if-present', 'ignore-scripts', 'foreground-scripts', 'script-shell', ] static name = 'run-script' static usage = ['<command> [-- <args>]'] static ignoreImplicitWorkspace = false static isShellout = true async completion (opts) { const argv = opts.conf.argv.remain if (argv.length === 2) { // find the script name const json = resolve(this.npm.localPrefix, 'package.json') const { scripts = {} } = await rpj(json).catch(er => ({})) return Object.keys(scripts) } } async exec (args) { if (args.length) { return this.run(args) } else { return this.list(args) } } async execWorkspaces (args, filters) { if (args.length) { return this.runWorkspaces(args, filters) } else { return this.listWorkspaces(args, filters) } } async run ([event, ...args], { path = this.npm.localPrefix, pkg } = {}) { // this || undefined is because runScript will be unhappy with the default // null value const scriptShell = this.npm.config.get('script-shell') || undefined pkg = pkg || (await rpj(`${path}/package.json`)) const { scripts = {} } = pkg if (event === 'restart' && !scripts.restart) { scripts.restart = 'npm stop --if-present && npm start' } else if (event === 'env' && !scripts.env) { scripts.env = isWindowsShell ? 'SET' : 'env' } pkg.scripts = scripts if ( !Object.prototype.hasOwnProperty.call(scripts, event) && !(event === 'start' && (await isServerPackage(path))) ) { if (this.npm.config.get('if-present')) { return } const suggestions = await didYouMean(this.npm, path, event) throw new Error( `Missing script: "${event}"${suggestions}\n\nTo see a list of scripts, run:\n npm run` ) } // positional args only added to the main event, not pre/post const events = [[event, args]] if (!this.npm.config.get('ignore-scripts')) { if (scripts[`pre${event}`]) { events.unshift([`pre${event}`, []]) } if (scripts[`post${event}`]) { events.push([`post${event}`, []]) } } const opts = { path, args, scriptShell, stdio: 'inherit', stdioString: true, pkg, banner: !this.npm.silent, } for (const [event, args] of events) { await runScript({ ...opts, event, args, }) } } async list (args, path) { path = path || this.npm.localPrefix const { scripts, name, _id } = await rpj(`${path}/package.json`) const pkgid = _id || name const color = this.npm.color if (!scripts) { return [] } const allScripts = Object.keys(scripts) if (this.npm.silent) { return allScripts } if (this.npm.config.get('json')) { this.npm.output(JSON.stringify(scripts, null, 2)) return allScripts } if (this.npm.config.get('parseable')) { for (const [script, cmd] of Object.entries(scripts)) { this.npm.output(`${script}:${cmd}`) } return allScripts } const indent = '\n ' const prefix = ' ' const cmds = [] const runScripts = [] for (const script of allScripts) { const list = cmdList.includes(script) ? cmds : runScripts list.push(script) } const colorize = color ? chalk : nocolor if (cmds.length) { this.npm.output( `${colorize.reset(colorize.bold('Lifecycle scripts'))} included in ${colorize.green( pkgid )}:` ) } for (const script of cmds) { this.npm.output(prefix + script + indent + colorize.dim(scripts[script])) } if (!cmds.length && runScripts.length) { this.npm.output( `${colorize.bold('Scripts')} available in ${colorize.green(pkgid)} via \`${colorize.blue( 'npm run-script' )}\`:` ) } else if (runScripts.length) { this.npm.output(`\navailable via \`${colorize.blue('npm run-script')}\`:`) } for (const script of runScripts) { this.npm.output(prefix + script + indent + colorize.dim(scripts[script])) } this.npm.output('') return allScripts } async runWorkspaces (args, filters) { const res = [] await this.setWorkspaces(filters) for (const workspacePath of this.workspacePaths) { const pkg = await rpj(`${workspacePath}/package.json`) const runResult = await this.run(args, { path: workspacePath, pkg, }).catch(err => { log.error(`Lifecycle script \`${args[0]}\` failed with error:`) log.error(err) log.error(` in workspace: ${pkg._id || pkg.name}`) log.error(` at location: ${workspacePath}`) const scriptMissing = err.message.startsWith('Missing script') // avoids exiting with error code in case there's scripts missing // in some workspaces since other scripts might have succeeded if (!scriptMissing) { process.exitCode = 1 } return scriptMissing }) res.push(runResult) } // in case **all** tests are missing, then it should exit with error code if (res.every(Boolean)) { throw new Error(`Missing script: ${args[0]}`) } } async listWorkspaces (args, filters) { await this.setWorkspaces(filters) if (this.npm.silent) { return } if (this.npm.config.get('json')) { const res = {} for (const workspacePath of this.workspacePaths) { const { scripts, name } = await rpj(`${workspacePath}/package.json`) res[name] = { ...scripts } } this.npm.output(JSON.stringify(res, null, 2)) return } if (this.npm.config.get('parseable')) { for (const workspacePath of this.workspacePaths) { const { scripts, name } = await rpj(`${workspacePath}/package.json`) for (const [script, cmd] of Object.entries(scripts || {})) { this.npm.output(`${name}:${script}:${cmd}`) } } return } for (const workspacePath of this.workspacePaths) { await this.list(args, workspacePath) } } } module.exports = RunScript
Save
cmd:
run