(tree, args)
| 170 | |
| 171 | // Returns a list of items that can't be fulfilled by things found in the current arborist inventory |
| 172 | missingArgsFromTree (tree, args) { |
| 173 | if (tree.isLink) { |
| 174 | return this.missingArgsFromTree(tree.target, args) |
| 175 | } |
| 176 | |
| 177 | const foundNodes = [] |
| 178 | const missing = args.filter(a => { |
| 179 | const arg = npa(a) |
| 180 | const nodes = tree.children.values() |
| 181 | const argFound = [...nodes].every(node => { |
| 182 | // TODO: write tests for unmatching version specs |
| 183 | // this is hard to test atm but should be simple once we have a mocked registry again |
| 184 | if (arg.name !== node.name /* istanbul ignore next */ || ( |
| 185 | arg.version && |
| 186 | /* istanbul ignore next */ |
| 187 | !semver.satisfies(node.version, arg.version) |
| 188 | )) { |
| 189 | foundNodes.push(node) |
| 190 | return true |
| 191 | } |
| 192 | }) |
| 193 | return argFound |
| 194 | }) |
| 195 | |
| 196 | // remote nodes from the loaded tree in order to avoid dropping them later when reifying |
| 197 | for (const node of foundNodes) { |
| 198 | node.parent = null |
| 199 | } |
| 200 | |
| 201 | return missing |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | module.exports = Link |
no test coverage detected