Skip to content

Commit

Permalink
chore: sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Feb 21, 2024
1 parent b108c02 commit dcd926c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions build_runtime_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,20 @@ function buildAsset({
obj.standataConfig = yaml.load(fileContent);

obj.filesMapByName = {};

// Check duplicate filenames for sanity
const filenames = obj.standataConfig.entities.map((entity) => entity.filename);
const duplicateFilenames = filenames.filter(
(filename, index) => filenames.indexOf(filename) !== index,
);
if (duplicateFilenames.length > 0) {
throw new Error(`Duplicate filenames found in ${assetPath}: ${duplicateFilenames}`);
}
// Create JSON
obj.standataConfig.entities?.forEach((entity) => {
const entityPath = path.join(path.dirname(assetPath), entity.filename);
const content = fs.readFileSync(path.resolve(entityPath), { encoding: "utf-8" });
console.log({ content, entityPath });
obj.filesMapByName[entity.filename] = JSON.parse(content);
});
fs.writeFileSync(targetPath, contentGenerator(obj), "utf8");
Expand Down

0 comments on commit dcd926c

Please sign in to comment.