Files

24 lines
770 B
JavaScript
Raw Permalink Normal View History

import path from 'path';
import categories from '../categories.json' assert { type: 'json' };
2024-07-07 21:32:32 +02:00
import {
mergeArrays,
writeFile,
readAllMetadata,
getCurrentDirPath,
} 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);
2024-02-01 22:38:21 +09:00
Object.keys(categories).forEach((categoryName) => {
categories[categoryName].forEach((iconName) => {
2023-02-16 08:26:29 +01:00
icons[iconName].categories = mergeArrays(icons[iconName].categories, [categoryName]);
});
});
2024-02-01 22:38:21 +09:00
Object.keys(icons).forEach((iconName) => {
2023-02-16 08:26:29 +01:00
const iconContent = JSON.stringify(icons[iconName], null, 2);
writeFile(iconContent, `${iconName}.json`, path.resolve(currentDir, '../icons'));
2024-02-01 22:38:21 +09:00
});