Skip to content

Commit 445e80e

Browse files
authored
Merge pull request #761 from mojavelinux/register-on-version-once
only register the option:version event once
2 parents f5abcdb + ba6592f commit 445e80e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,9 @@ Command.prototype.version = function(str, flags) {
855855
if (arguments.length === 0) return this._version;
856856
this._version = str;
857857
flags = flags || '-V, --version';
858-
var longOptIndex = flags.indexOf('--');
859-
this._versionOptionName = ~longOptIndex ? flags.substr(longOptIndex + 2) : 'version';
860-
this.option(flags, 'output the version number');
858+
var versionOption = new Option(flags, 'output the version number');
859+
this._versionOptionName = versionOption.long.substr(2) || 'version';
860+
this.options.push(versionOption);
861861
this.on('option:' + this._versionOptionName, function() {
862862
process.stdout.write(str + '\n');
863863
process.exit(0);

0 commit comments

Comments
 (0)