Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/busy-pianos-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/tree-walker": patch
---

fix(tree-walker): LocalDependencyTreeLoader fails resolving symlink location on macos
2 changes: 1 addition & 1 deletion workspaces/scanner/test/depWalker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe("depWalker", { concurrency: 2 }, () => {
{ path: "EntryFileAnalyser", filesCount: 17 },
{ path: "EntryFileAnalyser", filesCount: 47 },
{ path: "EntryFileAnalyser", filesCount: 67 },
{ path: "EntryFileAnalyser", filesCount: 210 }].sort(byFilesCount));
{ path: "EntryFileAnalyser", filesCount: 214 }].sort(byFilesCount));
});

function byFilesCount<T extends { filesCount: number; } | undefined>(a: T, b: T) {
Expand Down
11 changes: 7 additions & 4 deletions workspaces/tree-walker/src/npm/LocalDependencyTreeLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,26 @@ export class LocalDependencyTreeLoader implements LocalDependencyTreeLoaderProvi
options: LocalDependencyTreeLoaderOptions = {}
): Promise<TreeDependencies> {
const { registry, ...treeDepOptions } = options;
const resolvedLocation = await fs.realpath(location);

const arb = new Arborist({
...utils.NPM_TOKEN,
path: location,
path: resolvedLocation,
registry
});

try {
await fs.access(
path.join(location, "node_modules")
path.join(resolvedLocation, "node_modules")
);

await arb.loadActual();

const treeNode = await arb.buildIdealTree();
if (!arb.actualTree) {
throw new Error("arborist loadActual fn did not produce a tree");
}

return TreeDependencies.fromArboristNode(treeNode, treeDepOptions);
return TreeDependencies.fromArboristNode(arb.actualTree, treeDepOptions);
}
catch {
const treeNode = await arb.loadVirtual();
Expand Down