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

Method getNodes

deps/npm/lib/commands/explain.js:85–113  ·  view source on GitHub ↗
(tree, arg)

Source from the content-addressed store, hash-verified

83 }
84
85 getNodes (tree, arg) {
86 // if it's just a name, return packages by that name
87 const { validForOldPackages: valid } = validName(arg)
88 if (valid) {
89 return tree.inventory.query('packageName', arg)
90 }
91
92 // if it's a location, get that node
93 const maybeLoc = arg.replace(/\\/g, '/').replace(/(?<!\/)\/+$/, '')
94 const nodeByLoc = tree.inventory.get(maybeLoc)
95 if (nodeByLoc) {
96 return [nodeByLoc]
97 }
98
99 // maybe a path to a node_modules folder
100 const maybePath = relative(this.npm.prefix, resolve(maybeLoc))
101 .replace(/\\/g, '/').replace(/(?<!\/)\/+$/, '')
102 const nodeByPath = tree.inventory.get(maybePath)
103 if (nodeByPath) {
104 return [nodeByPath]
105 }
106
107 // otherwise, try to select all matching nodes
108 try {
109 return this.getNodesByVersion(tree, arg)
110 } catch {
111 return []
112 }
113 }
114
115 getNodesByVersion (tree, arg) {
116 const spec = npa(arg, this.npm.prefix)

Callers 1

execMethod · 0.95

Calls 5

getNodesByVersionMethod · 0.95
relativeFunction · 0.85
queryMethod · 0.65
getMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected