MCPcopy Create free account
hub / github.com/npm/cli / exec

Method exec

lib/commands/query.js:74–98  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

72 }
73
74 async exec (args) {
75 const packageLockOnly = this.npm.config.get('package-lock-only')
76 const Arborist = require('@npmcli/arborist')
77 const arb = new Arborist({
78 ...this.npm.flatOptions,
79 // one dir up from wherever node_modules lives
80 path: resolve(this.npm.dir, '..'),
81 forceActual: !packageLockOnly,
82 })
83 let tree
84 if (packageLockOnly) {
85 try {
86 tree = await arb.loadVirtual()
87 } catch (err) {
88 log.verbose('loadVirtual', err.stack)
89 throw this.usageError(
90 'A package lock or shrinkwrap file is required in package-lock-only mode'
91 )
92 }
93 } else {
94 tree = await arb.loadActual()
95 }
96 await this.#queryTree(tree, args[0])
97 this.#output()
98 }
99
100 async execWorkspaces (args) {
101 await this.setWorkspaces()

Callers

nothing calls this directly

Calls 7

#queryTreeMethod · 0.95
#outputMethod · 0.95
resolveFunction · 0.85
loadVirtualMethod · 0.80
usageErrorMethod · 0.80
loadActualMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected