Skip to content

Commit bc75566

Browse files
committed
fix: addons executed in the wrong order in certain circumstances
1 parent faa8f38 commit bc75566

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

.changeset/tricky-icons-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix: addons executed in the wrong order in certain circumstances

packages/cli/lib/install.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,16 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) {
180180
};
181181
}
182182

183-
// sorts them to their execution order
183+
// orders addons by putting addons that don't require any other addon in the front.
184+
// This is a drastic simplification, as this could still cause some inconvenient cituations,
185+
// but works for now in contrary to the previouse implementation
184186
function orderAddons(addons: Array<Addon<any>>, setupResults: Record<string, AddonSetupResult>) {
185-
return Array.from(addons).sort((a, b) => {
186-
const aDeps = setupResults[a.id].dependsOn;
187-
const bDeps = setupResults[b.id].dependsOn;
188-
189-
if (!aDeps && !bDeps) return 0;
190-
if (!aDeps) return -1;
191-
if (!bDeps) return 1;
192-
193-
if (aDeps.includes(b.id)) return 1;
194-
if (bDeps.includes(a.id)) return -1;
187+
return addons.sort((a, b) => {
188+
const aDepends = setupResults[a.id]?.dependsOn?.length > 0;
189+
const bDepends = setupResults[b.id]?.dependsOn?.length > 0;
195190

191+
if (aDepends && !bDepends) return 1;
192+
if (!aDepends && bDepends) return -1;
196193
return 0;
197194
});
198195
}

0 commit comments

Comments
 (0)