forked from oblador/react-native-vector-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-icon.js
executable file
·46 lines (39 loc) · 1.18 KB
/
generate-icon.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env node
'use strict';
var argv = require('yargs')
.usage('Usage: $0 [options] path/to/styles.css \nFor default template please provide --componentName and --fontFamily')
.demand(1)
.default('p', '.icon-')
.describe('p', 'CSS selector prefix')
.alias('p', 'prefix')
.default('t', __dirname + '/templates/bundled-icon-set.tpl')
.describe('t', 'Template in lodash format')
.alias('t', 'template')
.describe('o', 'Save output to file, defaults to STDOUT')
.alias('o', 'output')
.describe('g', 'Save glyphmap JSON to file')
.alias('g', 'glyphmap')
.argv;
var _ = require('lodash');
var fs = require('fs');
var generateIconSetFromCss = require('./lib/generate-icon-set-from-css');
var template;
if(argv.template) {
template = fs.readFileSync(argv.template, { encoding: 'utf8' });
}
var data = _.omit(argv, '_ $0 o output p prefix t template g glyphmap'.split(' '));
var content = generateIconSetFromCss(argv._, argv.prefix, template, data);
if(argv.output) {
fs.writeFileSync(
argv.output,
content
);
} else {
console.log(content);
}
if (argv.glyphmap) {
fs.writeFileSync(
argv.glyphmap,
generateIconSetFromCss(argv._, argv.prefix)
);
}