-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·33 lines (24 loc) · 741 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·33 lines (24 loc) · 741 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
#!/usr/bin/env node
const writeFile = require('write');
const stringify = require('json-stringify-pretty-compact');
const blowson = require('./dist/blowson');
const [, , ...args] = process.argv;
if (args.length < 2) {
console.log('Source and destination arguments missing!');
process.exit();
}
const src = './' + args[0];
const dest = './' + args[1];
const data = require(src);
try {
let parsedData = blowson(data);
if (typeof parsedData === 'string') {
writeFile.sync(dest, parsedData);
} else {
writeFile.sync(dest, `module.exports = ${stringify(blowson(parsedData))};`);
}
console.log('Sample data successfully extended!');
} catch (error) {
console.error(error);
}
process.exit();