2024-06-28 11:24:37 +02:00
|
|
|
import { writeFile } from '@lucide/helpers';
|
2025-06-18 15:47:24 +02:00
|
|
|
import { type SVGFile } from './readSvgs.mts';
|
2021-11-21 20:27:15 +01:00
|
|
|
|
2025-06-18 15:47:24 +02:00
|
|
|
export default async function generateIconNodes(parsedSvgs: SVGFile[], packageDir: string) {
|
2021-11-21 20:27:15 +01:00
|
|
|
const iconNodes = parsedSvgs.reduce((acc, { name, parsedSvg }) => {
|
|
|
|
|
acc[name] = parsedSvg.children.map(({ name, attributes }) => [name, attributes]);
|
|
|
|
|
|
|
|
|
|
return acc;
|
2025-06-18 15:47:24 +02:00
|
|
|
}, {} as Record<string, [string, Record<string, unknown> | undefined][]>);
|
2021-11-21 20:27:15 +01:00
|
|
|
|
|
|
|
|
const iconNodesStringified = JSON.stringify(iconNodes, null, 2);
|
|
|
|
|
|
2025-02-10 14:13:52 +01:00
|
|
|
await writeFile(iconNodesStringified, 'icon-nodes.json', packageDir);
|
2021-11-21 20:27:15 +01:00
|
|
|
}
|