(from, depth, chalk, seen)
| 94 | } |
| 95 | |
| 96 | const explainFrom = (from, depth, chalk, seen) => { |
| 97 | if (!from.name && !from.version) { |
| 98 | return 'the root project' |
| 99 | } |
| 100 | |
| 101 | // Prevent infinite recursion from cycles in the dependency graph (e.g. linked strategy store nodes). Use stack-based tracking so diamond dependencies (same node reached via different paths) are still explained, but recursive cycles are broken. |
| 102 | const nodeId = `${from.name}@${from.version}:${from.location}` |
| 103 | if (seen.has(nodeId)) { |
| 104 | return printNode(from, chalk) |
| 105 | } |
| 106 | seen.add(nodeId) |
| 107 | |
| 108 | const result = printNode(from, chalk) + |
| 109 | explainDependents(from, depth - 1, chalk, seen) + |
| 110 | explainLinksIn(from, depth - 1, chalk, seen) |
| 111 | |
| 112 | seen.delete(nodeId) |
| 113 | return result |
| 114 | } |
| 115 | |
| 116 | module.exports = { explainNode, printNode, explainEdge } |
no test coverage detected