Skip to content

Commit

Permalink
fix(core): fix pnpm local alias
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Dec 9, 2022
1 parent 4f2b809 commit b9fb228
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/nx/src/lock-file/__fixtures__/aux.lock.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO: add also { "eslint-plugin-disable-autofix": "npm:@mattlewis92/eslint-plugin-disable-autofix@3.0.0" } to devDependencies for test

export const npmLockFileWithAliases = `{
"name": "test",
"version": "0.0.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/nx/src/lock-file/lock-file.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ describe('lock-file', () => {
"version": "0.0.1",
}
`);

expect(lockFile).toEqual(npmLockFileWithAliases);
});
it('should properly parse, map and stringify yarn', () => {
const lockFileData = parseYarnLockFile(yarnLockFileWithAliases);
Expand All @@ -274,6 +276,8 @@ describe('lock-file', () => {
"version": "0.0.1",
}
`);

expect(lockFile).toEqual(yarnLockFileWithAliases);
});
it('should properly parse, map and stringify pnpm', () => {
const lockFileData = parsePnpmLockFile(pnpmLockFileWithAliases);
Expand All @@ -294,6 +298,8 @@ describe('lock-file', () => {
"version": "0.0.1",
}
`);

expect(lockFile).toEqual(pnpmLockFileWithAliases);
});
});
});
15 changes: 9 additions & 6 deletions packages/nx/src/lock-file/utils/hashing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ function traverseExternalNodesDependencies(
) {
graph.dependencies[projectName].forEach((d) => {
const target = graph.externalNodes[d.target];
const targetKey = `${target.data.packageName}@${target.data.version}`;

if (visited.indexOf(targetKey) === -1) {
visited.push(targetKey);
if (graph.dependencies[d.target]) {
traverseExternalNodesDependencies(d.target, graph, visited);
try {
const targetKey = `${target.data.packageName}@${target.data.version}`;
if (visited.indexOf(targetKey) === -1) {
visited.push(targetKey);
if (graph.dependencies[d.target]) {
traverseExternalNodesDependencies(d.target, graph, visited);
}
}
} catch (e) {
console.log(d.target, Object.keys(graph.externalNodes));
}
});
}
Expand Down

0 comments on commit b9fb228

Please sign in to comment.