chore(scripts): update boxicons script to use packs instead of weights

This commit is contained in:
Elian Doran 2025-12-28 22:29:42 +02:00
parent dbfaad6c06
commit ed229e0578
No known key found for this signature in database

View File

@ -7,12 +7,15 @@ if (!inputDir) {
process.exit(1);
}
for (const weight of [ "200", "400" ]) {
const jsonPath = `${inputDir}/${weight}/boxicons.json`;
for (const pack of [ "basic", "brands" ]) {
const fileName = pack === "basic" ? "boxicons" : `boxicons-${pack}`;
const jsonPath = `${inputDir}/${pack}/${fileName}.json`;
const inputData = JSON.parse(readFileSync(jsonPath, "utf-8"));
const icons = {};
for (const [ key, value ] of Object.entries(inputData)) {
if (key.startsWith("variable-selector")) continue;
let name = key;
if (name.startsWith('bx-')) {
name = name.slice(3);
@ -21,15 +24,14 @@ for (const weight of [ "200", "400" ]) {
name = name.slice(4);
}
icons[key] = {
glyph: String.fromCharCode(value as number),
glyph: String.fromCodePoint(value as number),
terms: [ name ]
};
}
const manifest = {
prefix: `bx3-${weight}`,
icons
};
const outputPath = join(`${inputDir}/${weight}/generated-manifest.json`);
const outputPath = join(`${inputDir}/${pack}/generated-manifest.json`);
writeFileSync(outputPath, JSON.stringify(manifest, null, 2));
}