2022-05-02 19:21:15 +00:00
|
|
|
const fs = require('fs');
|
2023-08-09 19:15:10 +00:00
|
|
|
const customIcons = require('../app/containers/CustomIcon/selection.json');
|
2022-05-02 19:21:15 +00:00
|
|
|
|
2023-08-09 19:15:10 +00:00
|
|
|
const sortObject = o => Object.keys(o).sort().reduce((r, k) => (r[k] = o[k], r), {});
|
|
|
|
|
|
|
|
let icons = {};
|
|
|
|
|
|
|
|
// map icons
|
|
|
|
customIcons.icons.forEach((icon) => {
|
2022-05-02 19:21:15 +00:00
|
|
|
icon.properties.name.split(/\s*,\s*/g).forEach((name) => {
|
2023-08-09 19:15:10 +00:00
|
|
|
icons = {...icons, [name]: icon.properties.code};
|
2022-05-02 19:21:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-08-09 19:15:10 +00:00
|
|
|
// sort icons by name
|
|
|
|
icons = sortObject(icons);
|
|
|
|
|
|
|
|
// generate mappedIcons file
|
|
|
|
let mappedIcons = 'export const mappedIcons = {\n';
|
|
|
|
|
|
|
|
// map icons to file
|
|
|
|
Object.keys(icons).forEach((icon)=> {
|
|
|
|
mappedIcons += `\t'${icon}': ${icons[icon]},\n`;
|
|
|
|
});
|
|
|
|
|
|
|
|
// close file
|
|
|
|
mappedIcons = `${mappedIcons.slice(0, -2) }\n};\n`;
|
|
|
|
|
|
|
|
// write file
|
|
|
|
fs.writeFile('app/containers/CustomIcon/mappedIcons.js', mappedIcons, 'utf8', function (err) {
|
2022-05-02 19:21:15 +00:00
|
|
|
if (err) {
|
|
|
|
console.log('An error occurred while writing Object to File.');
|
|
|
|
console.log(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-09 19:15:10 +00:00
|
|
|
console.log('🚀 Icons name generated.');
|
2022-05-02 19:21:15 +00:00
|
|
|
});
|