@expo/vector-icons
Version:
Built-in support for popular icon fonts and the tooling to create your own Icon components from your font and glyph map. This is a wrapper around react-native-vector-icons to make it compatible with Expo.
34 lines (25 loc) • 754 B
JavaScript
/* eslint-disable no-console */
const fs = require('fs');
const yargs = require('yargs');
const { argv } = yargs.usage('Usage: $0 [icons...]').help();
const icons = argv._;
for (let i = 0; i < icons.length; i += 1) {
const icon = icons[i];
let mapFile = icon;
if (mapFile === 'FontAwesome5') {
mapFile = 'FontAwesome5Free';
}
const glyphmap = JSON.parse(
fs.readFileSync(`glyphmaps/${mapFile}.json`, { encoding: 'utf8' })
);
const names = Object.keys(glyphmap).join("' | '");
const iconClass = `/**
* @flow strict
*/
import type { Icon } from './index';
export type ${icon}Glyphs = '${names}';
declare export default Class<Icon<${icon}Glyphs>>;
`;
fs.writeFileSync(`${icon}.js.flow`, iconClass);
}