| 108 | } |
| 109 | |
| 110 | const detectErrors = (node) => { |
| 111 | const errors = [] |
| 112 | |
| 113 | // Look for missing dependencies (that are NOT optional), or invalid dependencies |
| 114 | for (const edge of node.edgesOut.values()) { |
| 115 | if (edge.missing && !(edge.type === 'optional' || edge.type === 'peerOptional')) { |
| 116 | errors.push(`missing: ${edge.name}@${edge.spec}, required by ${edge.from.pkgid}`) |
| 117 | } |
| 118 | |
| 119 | if (edge.invalid) { |
| 120 | /* istanbul ignore next */ |
| 121 | const spec = edge.spec || '*' |
| 122 | const from = edge.from.pkgid |
| 123 | errors.push(`invalid: ${edge.to.pkgid}, ${spec} required by ${from}`) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | return errors |
| 128 | } |
| 129 | |
| 130 | module.exports = SBOM |