diff --git a/packages/histoire/src/node/build.ts b/packages/histoire/src/node/build.ts index a1b3fb96..5f8603a4 100644 --- a/packages/histoire/src/node/build.ts +++ b/packages/histoire/src/node/build.ts @@ -53,9 +53,7 @@ export async function build (ctx: Context) { server, throws: true, }, ctx) - for (const storyFile of ctx.storyFiles) { - await executeStoryFile(storyFile) - } + await Promise.all(ctx.storyFiles.map(storyFile => executeStoryFile(storyFile))) await destroyCollectStories() const storyCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ? 1 : 0), 0) diff --git a/packages/histoire/src/node/server.ts b/packages/histoire/src/node/server.ts index cc3ee02c..c008b30d 100644 --- a/packages/histoire/src/node/server.ts +++ b/packages/histoire/src/node/server.ts @@ -110,15 +110,12 @@ export async function createServer (ctx: Context, port: number) { await executeStoryFile(changedFile) // Queued updates - for (const storyFile of queuedFiles) { - await executeStoryFile(storyFile) - } + await Promise.all(queuedFiles.map(storyFile => executeStoryFile(storyFile))) } else { // Full update - for (const storyFile of ctx.storyFiles) { - await executeStoryFile(storyFile) - } + await Promise.all(ctx.storyFiles.map(storyFile => executeStoryFile(storyFile))) didAllStoriesYet = true + server.ws.send('histoire:all-stories-loaded', {}) } console.log('Collect stories end', Date.now() - time, 'ms')