Skip to content

Commit

Permalink
fix: throw on duplicates (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
amje authored Oct 30, 2023
1 parent 76ec30b commit 1245bf5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function createSvgBuilder(metadata) {
return async function svgBuilder([{children, components: icons}]) {
const iconSets = children.filter(({type}) => type === 'COMPONENT_SET');
const iconsById = icons.reduce((acc, item) => ({...acc, [item.id]: item}), {});
const uniqueIcons = new Set();

iconSets.sort((a, b) => (a.name > b.name ? 1 : -1));

Expand All @@ -49,6 +50,12 @@ function createSvgBuilder(metadata) {
throw new Error(`Icon has incorrect name: ${iconSet.name}`);
}

if (uniqueIcons.has(iconSet.name)) {
throw new Error(`Icon has been already added: ${iconSet.name}`);
} else {
uniqueIcons.add(iconSet.name);
}

for (const icon of iconSet.children) {
const props = parsePropertiesString(icon.name);
const svg = iconsById[icon.id].svg;
Expand Down

0 comments on commit 1245bf5

Please sign in to comment.