forked from smartsheet/smartsheet-sdk-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapply_defaults.js
27 lines (22 loc) · 902 Bytes
/
apply_defaults.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
var fs = require('fs');
var _ = require('underscore');
var scenarioDefaults = require('./lib/scenario_defaults');
var argv = require('yargs')
.alias('s', 'scenarios')
.describe('s', 'Path of JSON scenarios file')
.alias('d', 'defaults')
.describe('d', 'Path of JSON defaults file')
.alias('o', 'output')
.describe('o', 'Path to output a new scenarios file with defaults. Outputs to STDOUT if not specified')
.demandOption(['scenarios', 'defaults'])
.argv;
var scenarios = JSON.parse(fs.readFileSync(argv.scenarios));
var defaults = JSON.parse(fs.readFileSync(argv.defaults));
var scenariosWithDefaults = scenarioDefaults.buildScenariosWithDefaults(scenarios, defaults);
var scenarioJson = JSON.stringify(scenariosWithDefaults, null, ' ');
if (_.isUndefined(argv.output)) {
console.log(scenarioJson);
}
else {
fs.writeFileSync(argv.output, scenarioJson);
}