Skip to content

Commit

Permalink
fix(core): fix broken path elevation in npm lockfile pruning (#15833)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Mar 22, 2023
1 parent c7e49c5 commit 8cd410a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/nx/src/lock-file/npm-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,20 @@ function elevateNestedPaths(
`${segs.join('/node_modules/')}/node_modules/${packageName}`;

// check if grandparent has the same package
while (
segments.length > 1 &&
!result.has(getNewPath(segments.slice(0, -1)))
) {
const shouldElevate = (segs: string[]) => {
const newPath = getNewPath(segs.slice(0, -1));
if (result.has(newPath)) {
const match = result.get(newPath);
const source = remappedPackages.get(path);
return (
match.valueV1?.version === source.valueV1?.version &&
match.valueV3?.version === source.valueV3?.version
);
}
return true;
};

while (segments.length > 1 && shouldElevate(segments)) {
segments.pop();
}
const newPath = getNewPath(segments);
Expand Down

1 comment on commit 8cd410a

@vercel
Copy link

@vercel vercel bot commented on 8cd410a Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.