Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yarn version which yields same output as yarn --version (#2491) #2510

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ for (let i = 0; i < args.length; i++) {
}
}

// NOTE: Pending resolution of https://github.com/tj/commander.js/issues/346
// Remove this (and subsequent use in the logic below) after bug is resolved and issue is closed
const ARGS_THAT_SHARE_NAMES_WITH_OPTIONS = [
'version',
];

// set global options
commander.version(pkg.version);
commander.usage('[command] [flags]');
Expand Down Expand Up @@ -172,6 +178,11 @@ if (commandName === 'help' || args.indexOf('--help') >= 0 || args.indexOf('-h')

// parse flags
args.unshift(commandName);

if (ARGS_THAT_SHARE_NAMES_WITH_OPTIONS.indexOf(commandName) >= 0 && args[0] === commandName) {
args.shift();
}

commander.parse(startArgs.concat(args));
commander.args = commander.args.concat(endArgs);

Expand Down