Skip to content

Commit 6623b75

Browse files
committed
review changes
1 parent bcd771f commit 6623b75

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

workspaces/arborist/lib/calc-dep-flags.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const calcDepFlagsStep = (node) => {
5454
// If this is a peer edge, mark the target as peer
5555
if (peer) {
5656
to.peer = true
57+
} else if (to.peer && !hasIncomingPeerEdge(to)) {
58+
unsetFlag(to, 'peer')
5759
}
5860

5961
// devOptional is the *overlap* of the dev and optional tree.
@@ -66,11 +68,6 @@ const calcDepFlagsStep = (node) => {
6668
// either the dev or opt trees
6769
const unsetDev = unsetDevOpt || !node.dev && !dev
6870
const unsetOpt = unsetDevOpt || !node.optional && !optional
69-
const unsetPeer = !peer && !hasIncomingPeerEdge(to)
70-
71-
if (unsetPeer) {
72-
unsetFlag(to, 'peer')
73-
}
7471

7572
if (unsetDevOpt) {
7673
unsetFlag(to, 'devOptional')
@@ -124,7 +121,7 @@ const unsetFlag = (node, flag) => {
124121
const children = []
125122
const targetNode = node.isLink && node.target ? node.target : node
126123
for (const edge of targetNode.edgesOut.values()) {
127-
if (edge.to && edge.to[flag]) {
124+
if (edge.to?.[flag]) {
128125
// For the peer flag, only follow peer edges to unset the flag
129126
// Don't propagate peer flag through prod/dev/optional edges
130127
if (flag === 'peer') {
@@ -133,7 +130,7 @@ const unsetFlag = (node, flag) => {
133130
}
134131
} else {
135132
// For other flags, follow prod edges (and peer edges for non-peer flags)
136-
if (edge.type === 'prod' || (flag !== 'peer' && edge.type === 'peer')) {
133+
if (edge.type === 'prod' || edge.type === 'peer') {
137134
children.push(edge.to)
138135
}
139136
}

0 commit comments

Comments
 (0)