2022-11-07 11:34:40 +01:00
|
|
|
import path from 'path';
|
|
|
|
|
import categories from '../categories.json' assert { type: 'json' };
|
2024-07-01 21:28:11 +02:00
|
|
|
import { mergeArrays, writeFile, readAllMetadata, getCurrentDirPath } from '../tools/build-helpers/helpers.mjs';
|
2022-11-07 11:34:40 +01:00
|
|
|
|
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);
|
2022-11-07 11:34:40 +01:00
|
|
|
|
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]);
|
2022-11-07 11:34:40 +01:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
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
|
|
|
});
|