diff --git a/src/core/bundle.ts b/src/core/bundle.ts index ee815bf8..f9d2cabb 100644 --- a/src/core/bundle.ts +++ b/src/core/bundle.ts @@ -188,7 +188,7 @@ export async function resolveBundleIcons(options: ResolveBundleIconsOptions): Pr } return { - collections: [...collections.values()], + collections: [...collections.values()].sort((a, b) => a.prefix < b.prefix ? -1 : a.prefix > b.prefix ? 1 : 0), count, failed, dropped, diff --git a/test/bundle.test.ts b/test/bundle.test.ts index 934b3a3f..731da36d 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -42,6 +42,21 @@ afterAll(() => { rmSync(root, { recursive: true, force: true }) }) +it('returns collections in the same order regardless of icon order', async () => { + const customCollections = ['zeta', 'alpha'].map(prefix => ({ + prefix, + icons: { example: { body: '' } }, + width: 24, + height: 24, + })) + const options = { customCollections, resolvePaths: [root] } + const first = await resolveBundleIcons({ ...options, icons: ['zeta:example', 'alpha:example'] }) + const second = await resolveBundleIcons({ ...options, icons: ['alpha:example', 'zeta:example'] }) + + expect(first.collections.map(collection => collection.prefix)).toEqual(['alpha', 'zeta']) + expect(first.collections).toEqual(second.collections) +}) + it('resolves explicit, scanned and extra icons', async () => { const result = await resolveBundleIcons({ icons: ['test-bundle:foo'],