Skip to content

Commit

Permalink
fix: issue with arborist reported at npm#5007
Browse files Browse the repository at this point in the history
used fix suggested in npm#5007 (comment)
  • Loading branch information
zkochan committed Nov 1, 2023
1 parent e0fc634 commit 0af133e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions workspaces/arborist/lib/calc-dep-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const calcDepFlagsStep = (node) => {
resetParents(node, 'optional')

// for links, map their hierarchy appropriately
if (node.isLink) {
if (node.isLink && node.target) {
node.target.dev = node.dev
node.target.optional = node.optional
node.target.devOptional = node.devOptional
Expand Down Expand Up @@ -97,17 +97,19 @@ const unsetFlag = (node, flag) => {
tree: node,
visit: node => {
node.extraneous = node[flag] = false
if (node.isLink) {
if (node.isLink && node.target) {
node.target.extraneous = node.target[flag] = false
}
},
getChildren: node => {
const children = []
for (const edge of node.target.edgesOut.values()) {
if (edge.to && edge.to[flag] &&
(flag !== 'peer' && edge.type === 'peer' || edge.type === 'prod')
) {
children.push(edge.to)
if (node.target) {
for (const edge of node.target.edgesOut.values()) {
if (edge.to && edge.to[flag] &&
(flag !== 'peer' && edge.type === 'peer' || edge.type === 'prod')
) {
children.push(edge.to)
}
}
}
return children
Expand Down
2 changes: 1 addition & 1 deletion workspaces/arborist/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@npmcli/arborist",
"name": "@pnpm/arborist__fork",
"version": "7.2.1",
"description": "Manage node_modules trees",
"dependencies": {
Expand Down

0 comments on commit 0af133e

Please sign in to comment.