fix: an edge case with peer resolutions and circular deps (#4588)

This commit is contained in:
Zoltan Kochan
2022-04-18 23:06:02 +03:00
committed by GitHub
parent e941499872
commit 948a8151ed
2 changed files with 9 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
"pnpm": patch
---
Fix an error with peer resolutions, which was happening when there was a circular dependency and another dependency that had the name of the circular dependency as a substring.

View File

@@ -334,17 +334,17 @@ function getPreviouslyResolvedChildren<T extends PartialResolvedPackage> (nodeId
if (!ownId || !parentIds.includes(ownId)) return allChildren
const nodeIdChunks = parentIds.join('>').split(ownId)
const nodeIdChunks = parentIds.join('>').split(`>${ownId}>`)
nodeIdChunks.pop()
nodeIdChunks.reduce((accNodeId, part) => {
accNodeId += `${part}${ownId}`
accNodeId += `>${part}>${ownId}`
const parentNode = dependenciesTree[`${accNodeId}>`]
Object.assign(
allChildren,
typeof parentNode.children === 'function' ? parentNode.children() : parentNode.children
)
return accNodeId
}, '>')
}, '')
return allChildren
}