Skip to content

Commit

Permalink
fix(dev): prevent duplicate stream definitions
Browse files Browse the repository at this point in the history
This prevents shared/duplicate stream definitions from appearing multiple
times in features.json. If conflicting stream definitions exist for the
same stream ID, an error is thrown.
  • Loading branch information
briantstephan committed Oct 16, 2023
1 parent 07d77e9 commit 673dae2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/pages/src/generate/templates/createTemplatesJson.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from "fs-extra";
import isEqual from "lodash/isEqual";
import path from "path";
import {
FeaturesConfig,
Expand Down Expand Up @@ -86,8 +87,20 @@ export const getTemplatesConfig = (
const featureConfig = convertTemplateConfigToFeatureConfig(module.config);
features.push(featureConfig);
const streamConfig = convertTemplateConfigToStreamConfig(module.config);
if (streamConfig) {
if (!streamConfig) {
continue;
}
const matchingStreamConfig = streams.find(
(stream) => stream.$id === streamConfig.$id
);
if (!matchingStreamConfig) {
streams.push(streamConfig);
continue;
}
if (!isEqual(matchingStreamConfig, streamConfig)) {
throw new Error(
"Conflicting configurations found for stream ID ${streamConfig.$id}"
);
}
}

Expand Down

0 comments on commit 673dae2

Please sign in to comment.