1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 | const fs = require('fs');
|
5 | const yargs = require('yargs');
|
6 |
|
7 | const { argv } = yargs.usage('Usage: $0 [icons...]').help();
|
8 |
|
9 | const icons = argv._;
|
10 | for (let i = 0; i < icons.length; i += 1) {
|
11 | const icon = icons[i];
|
12 | let mapFile = icon;
|
13 | if (mapFile === 'FontAwesome5') {
|
14 | mapFile = 'FontAwesome5Free';
|
15 | }
|
16 |
|
17 | const glyphmap = JSON.parse(
|
18 | fs.readFileSync(`glyphmaps/${mapFile}.json`, { encoding: 'utf8' })
|
19 | );
|
20 | const names = Object.keys(glyphmap).join("' | '");
|
21 |
|
22 | const iconClass = `/**
|
23 | * @flow strict
|
24 | */
|
25 |
|
26 | import type { Icon } from './index';
|
27 |
|
28 | export type ${icon}Glyphs = '${names}';
|
29 |
|
30 | declare export default Class<Icon<${icon}Glyphs>>;
|
31 | `;
|
32 | fs.writeFileSync(`${icon}.js.flow`, iconClass);
|
33 | }
|