-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcft-simulator.js
39 lines (34 loc) · 1010 Bytes
/
cft-simulator.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
"use strict";
var _ = require('lodash');
var fs = require('fs');
var simulator = require('./processors-pipeline');
var program = require('commander');
program
.version('0.3.0')
.usage('[options] <file>')
.option('-p, --params <env>', 'a JSON formatted object. Example: -p \'{"env":"prod","port":80}\' ')
.parse(process.argv);
if (program.args.length === 0) {
console.error('no CFT file path was provided');
process.exit(1);
}
var file = program.args[0];
console.error("* params: ", program.params);
console.error("* file: ", file);
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.error(err);
process.exit(1);
}
else {
try {
var resultObj = simulator.process(data,program);
// print result to standard output
console.log(JSON.stringify(resultObj));
}
catch (ex) {
console.error("Processing error occured: ", ex);
process.exit(1);
}
}
});