UNPKG

697 BJavaScriptView Raw
1#!/usr/bin/env node
2/* eslint-disable no-console */
3
4const fs = require('fs');
5const yargs = require('yargs');
6
7const { argv } = yargs
8 .usage('')
9 .option('path', {
10 alias: 'p',
11 string: true,
12 })
13 .option('output', {
14 alias: 'o',
15 string: true,
16 })
17 .demandOption('path')
18 .demandOption('output');
19
20const path = `${argv.path}/svgs/`;
21
22const generatedJSON = {};
23fs.readdirSync(path)
24 .filter(file => fs.statSync(path + file).isDirectory())
25 .forEach(file => {
26 const icons = fs.readdirSync(path + file);
27 generatedJSON[file] = icons.map(icon => icon.split('.')[0]);
28 });
29
30fs.writeFileSync(
31 argv.output,
32 `${JSON.stringify(generatedJSON, null, 2)}\r\n`,
33 'utf8'
34);