/opt/alt/alt-nodejs24/root/usr/lib/node_modules/npm/lib/commands
const pkgJson = require('@npmcli/package-json') const runScript = require('@npmcli/run-script') const { join, relative } = require('node:path') const { log, output } = require('proc-log') const completion = require('../utils/installed-shallow.js') const BaseCommand = require('../base-cmd.js') // npm explore <pkg>[@<version>] // open a subshell to the package folder. class Explore extends BaseCommand { static description = 'Browse an installed package' static name = 'explore' static usage = ['<pkg> [ -- <command>]'] static params = ['shell'] static ignoreImplicitWorkspace = false // TODO /* istanbul ignore next */ static async completion (opts, npm) { return completion(npm, opts) } async exec (args) { if (args.length < 1 || !args[0]) { throw this.usageError() } const pkgname = args.shift() // detect and prevent any .. shenanigans const path = join(this.npm.dir, join('/', pkgname)) if (relative(path, this.npm.dir) === '') { throw this.usageError() } // run as if running a script named '_explore', which we set to either // the set of arguments, or the shell config, and let @npmcli/run-script // handle all the escaping and PATH setup stuff. const { content: pkg } = await pkgJson.normalize(path).catch(er => { log.error('explore', `It doesn't look like ${pkgname} is installed.`) throw er }) const { shell } = this.npm.flatOptions pkg.scripts = { ...(pkg.scripts || {}), _explore: args.join(' ').trim() || shell, } if (!args.length) { output.standard(`\nExploring ${path}\nType 'exit' or ^D when finished\n`) } return runScript({ ...this.npm.flatOptions, pkg, path, event: '_explore', stdio: 'inherit', }).catch(er => { process.exitCode = typeof er.code === 'number' && er.code !== 0 ? er.code : 1 // if it's not an exit error, or non-interactive, throw it const isProcExit = er.message === 'command failed' && (typeof er.code === 'number' || /^SIG/.test(er.signal || '')) if (args.length || !isProcExit) { throw er } }) } } module.exports = Explore
.
Edit
..
Edit
access.js
Edit
adduser.js
Edit
audit.js
Edit
bugs.js
Edit
cache.js
Edit
ci.js
Edit
completion.js
Edit
config.js
Edit
dedupe.js
Edit
deprecate.js
Edit
diff.js
Edit
dist-tag.js
Edit
docs.js
Edit
doctor.js
Edit
edit.js
Edit
exec.js
Edit
explain.js
Edit
explore.js
Edit
find-dupes.js
Edit
fund.js
Edit
get.js
Edit
help-search.js
Edit
help.js
Edit
init.js
Edit
install-ci-test.js
Edit
install-test.js
Edit
install.js
Edit
link.js
Edit
ll.js
Edit
login.js
Edit
logout.js
Edit
ls.js
Edit
org.js
Edit
outdated.js
Edit
owner.js
Edit
pack.js
Edit
ping.js
Edit
pkg.js
Edit
prefix.js
Edit
profile.js
Edit
prune.js
Edit
publish.js
Edit
query.js
Edit
rebuild.js
Edit
repo.js
Edit
restart.js
Edit
root.js
Edit
run.js
Edit
sbom.js
Edit
search.js
Edit
set.js
Edit
shrinkwrap.js
Edit
star.js
Edit
stars.js
Edit
start.js
Edit
stop.js
Edit
team.js
Edit
test.js
Edit
token.js
Edit
undeprecate.js
Edit
uninstall.js
Edit
unpublish.js
Edit
unstar.js
Edit
update.js
Edit
version.js
Edit
view.js
Edit
whoami.js
Edit