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

Method execWorkspaces

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

#queryTreeMethod · 0.95
#outputMethod · 0.95
setWorkspacesMethod · 0.80
loadVirtualMethod · 0.80
usageErrorMethod · 0.80
loadActualMethod · 0.80
querySelectorAllMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected