Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Commit 383ccfc

Browse files
committed
Clarify problemEdges logic
1 parent c427fa9 commit 383ccfc

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

lib/arborist/build-ideal-tree.js

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -768,12 +768,43 @@ This is a one-time fix-up, please be patient...
768768
const bundled = new Set(bd || [])
769769

770770
return [...node.edgesOut.values()]
771-
.filter(edge => !bundled.has(edge.name) &&
772-
!(edge.to && this[_loadFailures].has(edge.to)) &&
773-
!(edge.to && edge.to.inShrinkwrap) &&
774-
(!edge.valid || !edge.to || this[_updateNames].includes(edge.name) ||
775-
this[_isVulnerable](edge.to) ||
776-
node.isRoot && this[_explicitRequests].has(edge.name)))
771+
.filter(edge => {
772+
773+
// If it's included in a bundle, we take whatever is specified.
774+
if (bundled.has(edge.name))
775+
return false
776+
777+
// If it's already been logged as a load failure, skip it.
778+
if (edge.to && this[_loadFailures].has(edge.to))
779+
return false
780+
781+
// If it's shrinkwrapped, we use what the shrinkwap wants.
782+
if (edge.to && edge.to.inShrinkwrap)
783+
return false
784+
785+
// If the edge has an error, there's a problem.
786+
if (!edge.valid)
787+
return true
788+
789+
// If the edge has no destination, that's a problem.
790+
if (!edge.to)
791+
return true
792+
793+
// If user has explicitly asked to update this package by name, it's a problem.
794+
if (this[_updateNames].includes(edge.name))
795+
return true
796+
797+
// If we're fixing a security vulnerability with this package, it's a problem.
798+
if (this[_isVulnerable](edge.to))
799+
return true
800+
801+
// If the user has explicitly asked to install this package, it's a problem.
802+
if (node.isRoot && this[_explicitRequests].has(edge.name))
803+
return true
804+
805+
// No problems!
806+
return false
807+
})
777808
}
778809

779810
async [_fetchManifest] (spec) {

0 commit comments

Comments
 (0)