Update tags (#224)
* Add script to add more tags * add tags * update tags * Fix tags
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
"build:es": "babel build -d dist/esm",
|
||||
"build:bundles": "rollup -c rollup.config.js",
|
||||
"optimize": "npx babel-node ./scripts/optimizeSvgs.js --presets @babel/env",
|
||||
"addtags": "npx babel-node ./scripts/addMissingKeysToTags.js --presets @babel/env",
|
||||
"test": "jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
41
scripts/addMissingKeysToTags.js
Normal file
41
scripts/addMissingKeysToTags.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import path from 'path';
|
||||
import tags from '../tags.json';
|
||||
import { readSvgDirectory, writeFile } from './helpers';
|
||||
|
||||
const ICONS_DIR = path.resolve(__dirname, '../icons');
|
||||
|
||||
console.log(`Read all tags`);
|
||||
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR);
|
||||
|
||||
const iconNames = svgFiles.map(icon => icon.split('.')[0]);
|
||||
|
||||
const iconTags = iconNames
|
||||
.map(iconName => ({
|
||||
name: iconName,
|
||||
tags: tags[iconName] || [],
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
const nameA = a.name;
|
||||
const nameB = b.name;
|
||||
|
||||
if (nameA < nameB) {
|
||||
return -1;
|
||||
}
|
||||
if (nameA > nameB) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// names must be equal
|
||||
return 0;
|
||||
});
|
||||
|
||||
const newTags = iconTags.reduce((acc, { name, tags }) => {
|
||||
acc[name] = tags;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const tagsContent = JSON.stringify(newTags, null, 2);
|
||||
|
||||
writeFile(tagsContent, 'tags.json', path.resolve(__dirname, '..'));
|
||||
@@ -1,5 +1,6 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import getArgumentOptions from 'minimist';
|
||||
|
||||
import renderIconsObject from './render/renderIconsObject';
|
||||
|
||||
Reference in New Issue
Block a user