-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·38 lines (32 loc) · 978 Bytes
/
main.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
#!/usr/bin/env node
const yargs = require('yargs');
const generate = require('./generator.js');
const argTypes = {
OUTPUT: 'output',
INPUT: 'input',
CLEAN: 'clean',
};
const argv = yargs
.usage(
`Usage: $0 --${argTypes.INPUT} <inputDir> --${argTypes.OUTPUT} <outputDir> --${argTypes.CLEAN}`,
)
.option(argTypes.INPUT, {
describe: 'Input directory containing SVG files',
demandOption: true,
type: 'string',
})
.option(argTypes.OUTPUT, {
describe: 'Output directory for generated React icon files',
demandOption: true,
type: 'string',
})
.option(argTypes.CLEAN, {
describe: 'Remove unnecessary attributes from SVG files',
type: 'boolean',
}).argv;
function checkSlash(dir) {
return dir.endsWith('/') ? dir : `${dir}/`;
}
argv[argTypes.INPUT] = checkSlash(argv[argTypes.INPUT]);
argv[argTypes.OUTPUT] = checkSlash(argv[argTypes.OUTPUT]);
generate(argv[argTypes.INPUT], argv[argTypes.OUTPUT], argv[argTypes.CLEAN]);