From 81f0b124766ac4fe86dbeeda2aa9498e4026103b Mon Sep 17 00:00:00 2001 From: atanasster Date: Tue, 7 Jul 2020 10:49:46 -0400 Subject: [PATCH] fix: checks for missing doc and duplicated title --- core/loader/src/store.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/loader/src/store.ts b/core/loader/src/store.ts index 44b1d768f..34c7f0a22 100644 --- a/core/loader/src/store.ts +++ b/core/loader/src/store.ts @@ -97,12 +97,20 @@ export const reserveStories = (filePaths: string[]) => { }; export const addStoriesDoc = (filePath: string, added: LoadingDocStore) => { const { components, packages, stories, doc } = added; + if (!doc) { + throw new FatalError(`Invalid store with no document ${filePath}`); + } + Object.keys(components).forEach(key => { store.components[key] = components[key]; }); Object.keys(packages).forEach(key => { store.packages[key] = packages[key]; }); + const { title } = doc; + if (store.stores.find(s => s.doc?.title === title)) { + throw new FatalError(`Duplicate document title "${title}"`); + } const storeStore = store.stores.find(s => s.filePath === filePath); if (storeStore) { storeStore.stories = stories;