From 14c30cfd35faebc2d30af4c6d36fae9f6c7b8899 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Fri, 26 Nov 2021 10:31:03 +1100 Subject: [PATCH] Sort globbed files for consistent ordering. For https://github.com/storybookjs/storybook/issues/16767 Apparently globby's order is non deterministic: https://github.com/sindresorhus/globby/issues/131 I wasn't able to reproduce in our tests but definitely saw the behaviour in the issue. --- lib/core-server/src/utils/StoryIndexGenerator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core-server/src/utils/StoryIndexGenerator.ts b/lib/core-server/src/utils/StoryIndexGenerator.ts index d2df6f28b3f7..f809cc430906 100644 --- a/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -50,7 +50,7 @@ export class StoryIndexGenerator { path.join(this.options.workingDir, specifier.directory, specifier.files) ); const files = await glob(fullGlob); - files.forEach((absolutePath: Path) => { + files.sort().forEach((absolutePath: Path) => { const ext = path.extname(absolutePath); const relativePath = path.relative(this.options.workingDir, absolutePath); if (!['.js', '.jsx', '.ts', '.tsx', '.mdx'].includes(ext)) {