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

Method findNodesForArgs

deps/npm/lib/utils/allow-scripts-cmd.js:190–221  ·  view source on GitHub ↗
(args, arb)

Source from the content-addressed store, hash-verified

188 }
189
190 findNodesForArgs (args, arb) {
191 // Match positional args against each node's trusted name. Registry deps
192 // use the URL-derived name; non-registry deps fall back to the dependency
193 // edge name. A version or range on the arg narrows the match to installed
194 // versions that satisfy it. Bundled deps are excluded for the same reason
195 // as --all. Args that match nothing are returned in `unmatched`.
196 const matched = []
197 const unmatched = []
198 for (const arg of args) {
199 const { name: wantName, range } = parsePositional(arg)
200 const found = []
201 for (const node of arb.actualTree.inventory.values()) {
202 if (node.isProjectRoot || node.isWorkspace || node.inBundle) {
203 continue
204 }
205 const { name, version } = trustedDisplay(node)
206 if (!name || name !== wantName) {
207 continue
208 }
209 if (range && (!version || !semver.satisfies(version, range, { loose: true }))) {
210 continue
211 }
212 found.push(node)
213 }
214 if (found.length === 0) {
215 unmatched.push(arg)
216 } else {
217 matched.push(...found)
218 }
219 }
220 return { matched, unmatched }
221 }
222
223 get logTitle () {
224 return this.constructor.name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()

Callers 1

runPositionalMethod · 0.95

Calls 3

parsePositionalFunction · 0.85
valuesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected