Skip to content

Commit

Permalink
fix: checks for missing doc and duplicated title
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 7, 2020
1 parent 4207a85 commit 81f0b12
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/loader/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 81f0b12

Please sign in to comment.