-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·46 lines (35 loc) · 950 Bytes
/
index.js
File metadata and controls
executable file
·46 lines (35 loc) · 950 Bytes
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 fs = require('fs');
var program = require('commander');
var convert = require('./lib/convert');
var version = require('./package.json').version;
main();
function main() {
program.version(version).
option('-i, --input <json>', 'Input JSON').
option('-o --output <directory>', 'Output directory').
parse(process.argv);
var input = program.input;
var output = program.output;
if(!input) {
return console.error('missing input');
}
if(!output) {
return console.error('missing output');
}
fs.readFile(input, {
encoding: 'utf8',
}, function(err, data) {
if(err) {
return console.error(err);
}
var json;
try {
json = JSON.parse(data);
convert(json, output);
} catch(e) {
return console.error('failed to parse JSON');
}
});
}