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

Method runPositional

lib/utils/allow-scripts-cmd.js:198–216  ·  view source on GitHub ↗
(args, arb)

Source from the content-addressed store, hash-verified

196 }
197
198 async runPositional (args, arb) {
199 const { matched, unmatched } = this.findNodesForArgs(args, arb)
200 if (unmatched.length > 0) {
201 throw Object.assign(
202 new Error(`No installed packages match: ${unmatched.join(', ')}`),
203 { code: 'ENOMATCH' }
204 )
205 }
206 const groups = this.groupByPackage(matched)
207 /* istanbul ignore if: matched is non-empty here; groups only empties when a
208 matched node has no trusted key, which groupByPackage already warns on */
209 if (Object.keys(groups).length === 0) {
210 throw Object.assign(
211 new Error(`No installed packages match: ${args.join(', ')}`),
212 { code: 'ENOMATCH' }
213 )
214 }
215 await this.writePolicyChanges(groups)
216 }
217
218 findNodesForArgs (args, arb) {
219 // Match positional args against each node's trusted name. Registry deps

Callers 1

runModeMethod · 0.95

Calls 3

findNodesForArgsMethod · 0.95
groupByPackageMethod · 0.95
writePolicyChangesMethod · 0.95

Tested by

no test coverage detected