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