Files

26 lines
817 B
JavaScript
Raw Permalink Normal View History

import path from 'path';
2024-07-01 21:28:11 +02:00
import { writeFile, getCurrentDirPath, readAllMetadata } from '../tools/build-helpers/helpers.mjs';
2024-02-01 22:38:21 +09:00
const currentDir = getCurrentDirPath(import.meta.url);
2023-02-16 08:26:29 +01:00
const ICONS_DIR = path.resolve(currentDir, '../icons');
const icons = readAllMetadata(ICONS_DIR);
const newCategories = {};
2024-02-01 22:38:21 +09:00
Object.keys(icons).forEach((iconName) => {
icons[iconName].categories.forEach((categoryName) => {
newCategories[categoryName] = newCategories[categoryName] || [];
newCategories[categoryName].push(iconName);
});
});
2024-02-01 22:38:21 +09:00
const ordered = Object.keys(newCategories)
.sort()
.reduce((obj, key) => {
obj[key] = newCategories[key];
return obj;
2024-02-01 22:38:21 +09:00
}, {});
const categoriesContent = JSON.stringify(ordered, null, 2);
writeFile(categoriesContent, 'categories.json', path.resolve(currentDir, '..'));