Skip to content

Commit

Permalink
Fix finding dependents for deactivation (#490)
Browse files Browse the repository at this point in the history
* Fix finding dependents for deactivation

* Remove console.log
  • Loading branch information
fcollonval authored Dec 12, 2022
1 parent 78947f4 commit 6e04a9a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/application/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,28 @@ namespace Private {
add(id);
}

const sorted = topologicSort(edges);
// Filter edges
// - Get all packages that dependent on the package to be deactivated
const newEdges = edges.filter(edge => edge[1] === id);
let oldSize = 0;
while (newEdges.length > oldSize) {
const previousSize = newEdges.length;
// Get all packages that dependent on packages that will be deactivated
const packagesOfInterest = new Set(newEdges.map(edge => edge[0]));
for (const poi of packagesOfInterest) {
edges
.filter(edge => edge[1] === poi)
.forEach(edge => {
// We check it is not already included to deal with circular dependencies
if (!newEdges.includes(edge)) {
newEdges.push(edge);
}
});
}
oldSize = previousSize;
}

const sorted = topologicSort(newEdges);
const index = sorted.findIndex(candidate => candidate === id);

if (index === -1) {
Expand Down

0 comments on commit 6e04a9a

Please sign in to comment.