Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2022-03-22 19:35:12 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-03-28 23:20:47 +0300
commitbd96ae4071f9cc8a65e741f414db12e98537971d (patch)
treeb144c4d935e02c1ec525081906830d3f548a8da3 /workspaces/arborist/lib
parent18b8b94357d8f57301fbaa0f1e5dc2cf1128bf3e (diff)
fix(arborist): identify and repair invalid nodes in the virtual tree
Diffstat (limited to 'workspaces/arborist/lib')
-rw-r--r--workspaces/arborist/lib/arborist/build-ideal-tree.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js
index 535a6ab7d..f3166c37e 100644
--- a/workspaces/arborist/lib/arborist/build-ideal-tree.js
+++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js
@@ -355,6 +355,21 @@ Try using the package name instead, e.g:
})
.then(tree => {
+ // search the virtual tree for invalid edges, if any are found add their source to
+ // the depsQueue so that we'll fix it later
+ depth({
+ tree,
+ getChildren: (node) => [...node.edgesOut.values()].map(edge => edge.to),
+ filter: node => node,
+ visit: node => {
+ for (const edge of node.edgesOut.values()) {
+ if (!edge.valid) {
+ this[_depsQueue].push(node)
+ break // no need to continue the loop after the first hit
+ }
+ }
+ },
+ })
// null the virtual tree, because we're about to hack away at it
// if you want another one, load another copy.
this.idealTree = tree