/home/techb158/.nvm/versions/node/v16.20.2/lib/node_modules/npm/lib/commands
NameSizeModeActions
access.js55850644editdlrm
adduser.js22530644editdlrm
audit.js122340644editdlrm
bin.js7290644editdlrm
birthday.js5080644editdlrm
bugs.js8150644editdlrm
cache.js72470644editdlrm
ci.js37150644editdlrm
completion.js91240644editdlrm
config.js83080644editdlrm
dedupe.js14050644editdlrm
deprecate.js21090644editdlrm
diff.js82910644editdlrm
dist-tag.js56040644editdlrm
docs.js4470644editdlrm
doctor.js94460644editdlrm
edit.js20470644editdlrm
exec.js24990644editdlrm
explain.js36390644editdlrm
explore.js23870644editdlrm
find-dupes.js6020644editdlrm
fund.js65240644editdlrm
get.js5240644editdlrm
help-search.js57550644editdlrm
help.js46370644editdlrm
hook.js40270644editdlrm
init.js69720644editdlrm
install-ci-test.js3770644editdlrm
install-test.js3740644editdlrm
install.js52360644editdlrm
link.js51410644editdlrm
ll.js2340644editdlrm
logout.js13770644editdlrm
ls.js173510644editdlrm
org.js43050644editdlrm
outdated.js90500644editdlrm
owner.js60180644editdlrm
pack.js24190644editdlrm
ping.js8740644editdlrm
pkg.js35540644editdlrm
prefix.js3430644editdlrm
profile.js115250644editdlrm
prune.js7790644editdlrm
publish.js64810644editdlrm
query.js28730644editdlrm
rebuild.js22140644editdlrm
repo.js12720644editdlrm
restart.js3510644editdlrm
root.js2980644editdlrm
run-script.js70670644editdlrm
search.js27810644editdlrm
set-script.js26980644editdlrm
set.js5720644editdlrm
shrinkwrap.js27050644editdlrm
star.js19110644editdlrm
stars.js10520644editdlrm
start.js3410644editdlrm
stop.js3360644editdlrm
team.js45450644editdlrm
test.js3360644editdlrm
token.js69540644editdlrm
uninstall.js15520644editdlrm
unpublish.js46170644editdlrm
unstar.js1820644editdlrm
update.js17380644editdlrm
version.js36900644editdlrm
view.js147230644editdlrm
whoami.js5140644editdlrm
Edit: /home/techb158/.nvm/versions/node/v16.20.2/lib/node_modules/npm/lib/commands/query.js (2873B)
'use strict' const { resolve } = require('path') const Arborist = require('@npmcli/arborist') const BaseCommand = require('../base-command.js') class QuerySelectorItem { constructor (node) { // all enumerable properties from the target Object.assign(this, node.target.package) // append extra info this.pkgid = node.target.pkgid this.location = node.target.location this.path = node.target.path this.realpath = node.target.realpath this.resolved = node.target.resolved this.from = [] this.to = [] this.dev = node.target.dev this.inBundle = node.target.inBundle this.deduped = this.from.length > 1 this.overridden = node.overridden for (const edge of node.target.edgesIn) { this.from.push(edge.from.location) } for (const [, edge] of node.target.edgesOut) { if (edge.to) { this.to.push(edge.to.location) } } } } class Query extends BaseCommand { #response = [] // response is the query response #seen = new Set() // paths we've seen so we can keep response deduped static description = 'Retrieve a filtered list of packages' static name = 'query' static usage = [''] static ignoreImplicitWorkspace = false static params = [ 'global', 'workspace', 'workspaces', 'include-workspace-root', ] get parsedResponse () { return JSON.stringify(this.#response, null, 2) } async exec (args) { // one dir up from wherever node_modules lives const where = resolve(this.npm.dir, '..') const opts = { ...this.npm.flatOptions, path: where, forceActual: true, } const arb = new Arborist(opts) const tree = await arb.loadActual(opts) const items = await tree.querySelectorAll(args[0]) this.buildResponse(items) this.npm.output(this.parsedResponse) } async execWorkspaces (args, filters) { await this.setWorkspaces(filters) const opts = { ...this.npm.flatOptions, path: this.npm.prefix, } const arb = new Arborist(opts) const tree = await arb.loadActual(opts) for (const workspacePath of this.workspacePaths) { let items if (workspacePath === tree.root.path) { // include-workspace-root items = await tree.querySelectorAll(args[0]) } else { const [workspace] = await tree.querySelectorAll(`.workspace:path(${workspacePath})`) items = await workspace.target.querySelectorAll(args[0]) } this.buildResponse(items) } this.npm.output(this.parsedResponse) } // builds a normalized inventory buildResponse (items) { for (const node of items) { if (!this.#seen.has(node.target.location)) { const item = new QuerySelectorItem(node) this.#response.push(item) this.#seen.add(item.location) } } } } module.exports = Query