Skip to content

Commit

Permalink
fix(scripts): fixes writeIconRelatedIcons.mjs (#2190)
Browse files Browse the repository at this point in the history
* fix(scripts): fixes writeIconRelatedIcons.mjs

* fix(scripts): fixes linting

---------

Co-authored-by: Karsa <[email protected]>
  • Loading branch information
karsa-mistmere and Karsa committed Jun 7, 2024
1 parent afbef74 commit 4b312b3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions scripts/writeIconRelatedIcons.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const nameParts = (icon) =>
const getRelatedIcons = (currentIcon, icons) => {
const iconSimilarity = (item) =>
nameWeight * arrayMatches(nameParts(item), nameParts(currentIcon)) +
categoryWeight * arrayMatches(item.categories, currentIcon.categories) +
tagWeight * arrayMatches(item.tags, currentIcon.tags);
categoryWeight * arrayMatches(item.categories ?? [], currentIcon.categories ?? []) +
tagWeight * arrayMatches(item.tags ?? [], currentIcon.tags ?? []);
return icons
.filter((i) => i.name !== currentIcon.name)
.map((icon) => ({ icon, similarity: iconSimilarity(icon) }))
Expand All @@ -54,9 +54,7 @@ const getRelatedIcons = (currentIcon, icons) => {

const iconsMetaDataPromises = svgFiles.map(async (iconName) => {
// eslint-disable-next-line import/no-dynamic-require, global-require
const metaData = await import(`../icons/${iconName}`, {
assert: { type: 'json' },
});
const metaData = JSON.parse(fs.readFileSync(`../icons/${iconName}`));

const name = iconName.replace('.json', '');

Expand Down

0 comments on commit 4b312b3

Please sign in to comment.