Skip to content
Myr

Merge pull request #728 from sorohan/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes issue #727: Passing empty string for option on command is set to undefined

authored by Tomoaki Abe · committed by GitHub · parents d5ac793, 06451e3 · Browse files · 2 files+23 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−3 removed

  • tests:+20 added−0 removed
  • other:+3 added−3 removed

2 files+23 added−3 removed

added:test/test.command.action.emptyOption.js+20 added
modified:index.js+3 added-3 removed
745 unmodified lines
746747 // If the next argument looks like it might be748 // an argument for this option, we pass it on.749 // If it isn't, then it'll simply be ignored750 if (argv[i + 1] && argv[i + 1][0] !== '-') {750 if ((i + 1) < argv.length && argv[i + 1][0] !== '-') {751 unknownOptions.push(argv[++i]);752 }753 continue;754 }
99 unmodified lines
854Command.prototype.version = function(str, flags) {855 if (arguments.length === 0) return this._version;856 this._version = str;857 flags = flags || '-V, --version';858 var longOptIndex = flags.indexOf('--')859 this._versionOptionName = ~longOptIndex ? flags.substr(longOptIndex + 2) : 'version'858 var longOptIndex = flags.indexOf('--');859 this._versionOptionName = ~longOptIndex ? flags.substr(longOptIndex + 2) : 'version';860 this.option(flags, 'output the version number');861 this.on('option:' + this._versionOptionName, function() {862 process.stdout.write(str + '\n');863 process.exit(0);
294 unmodified lines