From 1245bf5ac1dbf4792d226212aa452b94343d8947 Mon Sep 17 00:00:00 2001 From: Andrey Morozov Date: Tue, 31 Oct 2023 00:44:14 +0300 Subject: [PATCH] fix: throw on duplicates (#37) --- scripts/download.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/download.js b/scripts/download.js index 9068356..9b6fc77 100644 --- a/scripts/download.js +++ b/scripts/download.js @@ -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)); @@ -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;