it('should load config from apps', done => { spyOn(console, 'log').and.callFake(() => {}); commander.loadDefinitions(testDefinitions); commander.parse([ 'node', './CLI.spec.js', './spec/configs/CLIConfigApps.json', ]); const options = commander.getOptions(); expect(options.arg1).toBe('my_app'); expect(options.arg2).toBe(8888); expect(options.arg3).toBe('hello'); //config value expect(options.arg4).toBe('/1'); done(); });
export default function({ definitions, help, usage, start }) { program.loadDefinitions(definitions); if (usage) { program.usage(usage); } if (help) { program.on('--help', help); } program.parse(process.argv, process.env); const options = program.getOptions(); start(program, options, function() { logStartupOptions(options); }); }
it('should not override config.json', done => { spyOn(console, 'log').and.callFake(() => {}); commander.loadDefinitions(testDefinitions); commander.parse( [ 'node', './CLI.spec.js', '--arg0', 'arg0Value', './spec/configs/CLIConfig.json', ], { PROGRAM_ARG_0: 'arg0ENVValue', PROGRAM_ARG_1: 'arg1ENVValue', } ); const options = commander.getOptions(); expect(options.arg2).toBe(8888); expect(options.arg3).toBe('hello'); //config value expect(options.arg4).toBe('/1'); done(); });