Skip to content

Commit

Permalink
Merge pull request #761 from mojavelinux/register-on-version-once
Browse files Browse the repository at this point in the history
only register the option:version event once
  • Loading branch information
abetomo committed Feb 1, 2018
2 parents f5abcdb + ba6592f commit 445e80e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Expand Up @@ -855,9 +855,9 @@ Command.prototype.version = function(str, flags) {
if (arguments.length === 0) return this._version;
this._version = str;
flags = flags || '-V, --version';
var longOptIndex = flags.indexOf('--');
this._versionOptionName = ~longOptIndex ? flags.substr(longOptIndex + 2) : 'version';
this.option(flags, 'output the version number');
var versionOption = new Option(flags, 'output the version number');
this._versionOptionName = versionOption.long.substr(2) || 'version';
this.options.push(versionOption);
this.on('option:' + this._versionOptionName, function() {
process.stdout.write(str + '\n');
process.exit(0);
Expand Down

0 comments on commit 445e80e

Please sign in to comment.