You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
697 B
35 lines
697 B
#!/usr/bin/env node
|
|
/* eslint-disable no-console */
|
|
|
|
const fs = require('fs');
|
|
const yargs = require('yargs');
|
|
|
|
const { argv } = yargs
|
|
.usage('')
|
|
.option('path', {
|
|
alias: 'p',
|
|
string: true,
|
|
})
|
|
.option('output', {
|
|
alias: 'o',
|
|
string: true,
|
|
})
|
|
.demandOption('path')
|
|
.demandOption('output');
|
|
|
|
const path = `${argv.path}/svgs/`;
|
|
|
|
const generatedJSON = {};
|
|
fs.readdirSync(path)
|
|
.filter(file => fs.statSync(path + file).isDirectory())
|
|
.forEach(file => {
|
|
const icons = fs.readdirSync(path + file);
|
|
generatedJSON[file] = icons.map(icon => icon.split('.')[0]);
|
|
});
|
|
|
|
fs.writeFileSync(
|
|
argv.output,
|
|
`${JSON.stringify(generatedJSON, null, 2)}\r\n`,
|
|
'utf8'
|
|
);
|