mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 23:37:41 +01:00
26 lines
817 B
JavaScript
26 lines
817 B
JavaScript
import path from 'path';
|
|
import { writeFile, getCurrentDirPath, readAllMetadata } from '../tools/build-helpers/helpers.mjs';
|
|
|
|
const currentDir = getCurrentDirPath(import.meta.url);
|
|
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
|
const icons = readAllMetadata(ICONS_DIR);
|
|
|
|
const newCategories = {};
|
|
Object.keys(icons).forEach((iconName) => {
|
|
icons[iconName].categories.forEach((categoryName) => {
|
|
newCategories[categoryName] = newCategories[categoryName] || [];
|
|
newCategories[categoryName].push(iconName);
|
|
});
|
|
});
|
|
|
|
const ordered = Object.keys(newCategories)
|
|
.sort()
|
|
.reduce((obj, key) => {
|
|
obj[key] = newCategories[key];
|
|
return obj;
|
|
}, {});
|
|
|
|
const categoriesContent = JSON.stringify(ordered, null, 2);
|
|
|
|
writeFile(categoriesContent, 'categories.json', path.resolve(currentDir, '..'));
|