diff --git a/lib/parser.js b/lib/parser.js index 5ee9185cd7f..d9dcfa10a5e 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -782,7 +782,8 @@ function getParser () { let parser = new ArgumentParser({ version: pkgObj.version, addHelp: true, - description: 'A webdriver-compatible server for use with native and hybrid iOS and Android applications.' + description: 'A webdriver-compatible server for use with native and hybrid iOS and Android applications.', + prog: process.argv[1] || 'Appium' }); let allArgs = _.union(args, deprecatedArgs); parser.rawArgs = allArgs; diff --git a/test/config-specs.js b/test/config-specs.js index 3c1335f3cc0..ce9f398fc46 100644 --- a/test/config-specs.js +++ b/test/config-specs.js @@ -194,6 +194,30 @@ describe('Config', () => { }); }); + describe('parsing args with empty argv[1]', () => { + let argv1; + + before(() => { + argv1 = process.argv[1]; + }); + + after(() => { + process.argv[1] = argv1; + }); + + it('should not fail if process.argv[1] is undefined', () => { + process.argv[1] = undefined; + let args = getParser(); + args.prog.should.be.equal('Appium'); + }); + + it('should set "prog" to process.argv[1]', () => { + process.argv[1] = 'Hello World'; + let args = getParser(); + args.prog.should.be.equal('Hello World'); + }); + }); + describe('validateServerArgs', () => { let parser = getParser(); parser.debug = true; // throw instead of exit on error; pass as option instead?