MCPcopy Index your code
hub / github.com/nodejs/node / execWorkspaces

Method execWorkspaces

deps/npm/lib/commands/query.js:88–119  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

86 }
87
88 async execWorkspaces (args) {
89 await this.setWorkspaces()
90 const packageLockOnly = this.npm.config.get('package-lock-only')
91 const Arborist = require('@npmcli/arborist')
92 const arb = new Arborist({
93 ...this.npm.flatOptions,
94 path: this.npm.prefix,
95 forceActual: !packageLockOnly,
96 })
97 let tree
98 if (packageLockOnly) {
99 try {
100 tree = await arb.loadVirtual()
101 } catch (err) {
102 log.verbose('loadVirtual', err.stack)
103 throw this.usageError(
104 'A package lock or shrinkwrap file is required in package-lock-only mode'
105 )
106 }
107 } else {
108 tree = await arb.loadActual()
109 }
110 for (const path of this.workspacePaths) {
111 const wsTree = path === tree.root.path
112 ? tree // --includes-workspace-root
113 : await tree.querySelectorAll(`.workspace:path(${path})`).then(r => r[0]?.target)
114 if (wsTree) {
115 await this.#queryTree(wsTree, args[0])
116 }
117 }
118 this.#output()
119 }
120
121 #output () {
122 this.checkExpected(this.#response.length)

Callers

nothing calls this directly

Calls 9

#queryTreeMethod · 0.95
#outputMethod · 0.95
setWorkspacesMethod · 0.80
verboseMethod · 0.80
usageErrorMethod · 0.80
getMethod · 0.65
requireFunction · 0.50
thenMethod · 0.45
querySelectorAllMethod · 0.45

Tested by

no test coverage detected