Skip to content

Commit

Permalink
fix(js): filter project dependencies when calculating topological ord…
Browse files Browse the repository at this point in the history
…ering

For each project being sorted, only its dependent projects must be processed.
  • Loading branch information
mpsanchis committed Jun 10, 2024
1 parent ccc5ad5 commit 1cab740
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ export function sortProjectsTopologically(
sortedProjects.push(node);

// Process each project that depends on the current node
filteredDependencies.forEach((dep) => {
const dependentNode = projectGraph.nodes[dep.source];
const count = edges.get(dependentNode) - 1;
edges.set(dependentNode, count);
if (count === 0) {
processQueue.push(dependentNode);
}
});
filteredDependencies
.filter((dep) => dep.target === node.name)
.forEach((dep) => {
const dependentNode = projectGraph.nodes[dep.source];
const count = edges.get(dependentNode) - 1;
edges.set(dependentNode, count);
if (count === 0) {
processQueue.push(dependentNode);
}
});
}

/**
Expand Down

0 comments on commit 1cab740

Please sign in to comment.