(program)
| 74 | } |
| 75 | |
| 76 | function parseConfigFile(program) { |
| 77 | let options = {}; |
| 78 | if (program.args.length > 0) { |
| 79 | let jsonPath = program.args[0]; |
| 80 | jsonPath = path.resolve(jsonPath); |
| 81 | const jsonConfig = require(jsonPath); |
| 82 | if (jsonConfig.apps) { |
| 83 | if (jsonConfig.apps.length > 1) { |
| 84 | throw 'Multiple apps are not supported'; |
| 85 | } |
| 86 | options = jsonConfig.apps[0]; |
| 87 | } else { |
| 88 | options = jsonConfig; |
| 89 | } |
| 90 | Object.keys(options).forEach(key => { |
| 91 | const value = options[key]; |
| 92 | if (!_definitions[key]) { |
| 93 | throw `error: unknown option ${key}`; |
| 94 | } |
| 95 | const action = _definitions[key].action; |
| 96 | if (action) { |
| 97 | options[key] = action(value); |
| 98 | } |
| 99 | }); |
| 100 | console.log(`Configuration loaded from ${jsonPath}`); |
| 101 | } |
| 102 | return options; |
| 103 | } |
| 104 | |
| 105 | Command.prototype.setValuesIfNeeded = function (options) { |
| 106 | Object.keys(options).forEach(key => { |
no test coverage detected
searching dependent graphs…