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/tricky-icons-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

fix: addons executed in the wrong order in certain circumstances
20 changes: 6 additions & 14 deletions packages/cli/lib/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,11 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) {
};
}

// sorts them to their execution order
// orders addons by putting addons that don't require any other addon in the front.
// This is a drastic simplification, as this could still cause some inconvenient cituations,
// but works for now in contrary to the previouse implementation
function orderAddons(addons: Array<Addon<any>>, setupResults: Record<string, AddonSetupResult>) {
return Array.from(addons).sort((a, b) => {
const aDeps = setupResults[a.id].dependsOn;
const bDeps = setupResults[b.id].dependsOn;

if (!aDeps && !bDeps) return 0;
if (!aDeps) return -1;
if (!bDeps) return 1;

if (aDeps.includes(b.id)) return 1;
if (bDeps.includes(a.id)) return -1;

return 0;
});
return addons.sort(
(a, b) => setupResults[a.id]?.dependsOn?.length - setupResults[b.id]?.dependsOn?.length
);
}