Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix finding dependents for deactivation #490

Merged
merged 2 commits into from
Dec 12, 2022
Merged
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
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