Skip to content

Commit

Permalink
Update scripts/utils.js
Browse files Browse the repository at this point in the history
Co-authored-by: SanD <[email protected]>
  • Loading branch information
tristen and AlexanderBelokon authored Jan 3, 2025
1 parent c8e67e7 commit 0005add
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ async function gatherIcons(iconPath) {
const files = await readdir(iconPath);
const svgFiles = files.filter(f => f.endsWith('.svg'));

return Promise.all(
const svgs = await Promise.all(
svgFiles.map(f => readFile(path.join(iconPath, f), 'utf8'))
)
.then(svgs => {
return Promise.all(
svgs.map(svg => {
// Need to create a parser for each svg
const parser = new xml2js.Parser();
const pParse = pify(parser.parseString);
return pParse(svg);
})
);
);

const parsedSvgs = await Promise.all(
svgs.map(svg => {
// Need to create a parser for each svg
const parser = new xml2js.Parser();
const pParse = pify(parser.parseString);
return pParse(svg);
})
.then(parsedSvgs => {
return parsedSvgs.map((pSvg, i) => ({
fileName: svgFiles[i],
data: pSvg.svg
}));
});
);

return parsedSvgs.map((pSvg, i) => ({
fileName: svgFiles[i],
data: pSvg.svg
}));
}

async function write(cleanedSvgs, iconPath) {
Expand Down

0 comments on commit 0005add

Please sign in to comment.