mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-05-01 16:46:43 +03:00
Build icons in order (#7852)
This commit is contained in:
parent
d5444f6995
commit
fdc707bf81
@ -81,31 +81,29 @@ const build = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 'main'
|
// 'main'
|
||||||
const iconsBarrelMjs = [];
|
const buildIcons = await Promise.all(
|
||||||
const iconsBarrelJs = [];
|
|
||||||
const iconsBarrelDts = [];
|
|
||||||
const buildIcons = [];
|
|
||||||
|
|
||||||
await Promise.all(
|
|
||||||
icons.map(async (icon) => {
|
icons.map(async (icon) => {
|
||||||
const filename = getIconSlug(icon);
|
const filename = getIconSlug(icon);
|
||||||
const svgFilepath = path.resolve(iconsDir, `${filename}.svg`);
|
const svgFilepath = path.resolve(iconsDir, `${filename}.svg`);
|
||||||
icon.svg = (await fs.readFile(svgFilepath, UTF8)).replace(/\r?\n/, '');
|
icon.svg = (await fs.readFile(svgFilepath, UTF8)).replace(/\r?\n/, '');
|
||||||
icon.path = svgToPath(icon.svg);
|
icon.path = svgToPath(icon.svg);
|
||||||
icon.slug = filename;
|
icon.slug = filename;
|
||||||
buildIcons.push(icon);
|
|
||||||
|
|
||||||
const iconObject = iconToObject(icon);
|
const iconObject = iconToObject(icon);
|
||||||
|
|
||||||
const iconExportName = slugToVariableName(icon.slug);
|
const iconExportName = slugToVariableName(icon.slug);
|
||||||
|
return { icon, iconObject, iconExportName };
|
||||||
// add object to the barrel file
|
|
||||||
iconsBarrelJs.push(`${iconExportName}:${iconObject},`);
|
|
||||||
iconsBarrelMjs.push(`export const ${iconExportName}=${iconObject}`);
|
|
||||||
iconsBarrelDts.push(`export const ${iconExportName}:I;`);
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const iconsBarrelDts = [];
|
||||||
|
const iconsBarrelJs = [];
|
||||||
|
const iconsBarrelMjs = [];
|
||||||
|
|
||||||
|
buildIcons.forEach(({ icon, iconObject, iconExportName }) => {
|
||||||
|
iconsBarrelDts.push(`export const ${iconExportName}:I;`);
|
||||||
|
iconsBarrelJs.push(`${iconExportName}:${iconObject},`);
|
||||||
|
iconsBarrelMjs.push(`export const ${iconExportName}=${iconObject}`);
|
||||||
|
});
|
||||||
|
|
||||||
// constants used in templates to reduce package size
|
// constants used in templates to reduce package size
|
||||||
const constantsString = `const a='<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>',b='</title><path d="',c='"/></svg>';`;
|
const constantsString = `const a='<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>',b='</title><path d="',c='"/></svg>';`;
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ const build = async () => {
|
|||||||
const rawIndexJs = util.format(
|
const rawIndexJs = util.format(
|
||||||
indexTemplate,
|
indexTemplate,
|
||||||
constantsString,
|
constantsString,
|
||||||
buildIcons.map(iconToKeyValue).join(','),
|
buildIcons.map(({ icon }) => iconToKeyValue(icon)).join(','),
|
||||||
);
|
);
|
||||||
await writeJs(indexFile, rawIndexJs);
|
await writeJs(indexFile, rawIndexJs);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user