Skip to content

Commit

Permalink
Fix yarn version which yields same output as yarn --version (yarn…
Browse files Browse the repository at this point in the history
…pkg#2491)

There was a conflict when commander attempts to parse the incoming args
between the command executed and the options since the name `version`
was shared. In other words, executing the command `yarn version`
would yield the same output as `yarn --version`. This relates to PR yarnpkg#2268.
  • Loading branch information
Constantine Antonakos committed Jan 25, 2017
1 parent 93fa0f7 commit 5a55b7d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,13 @@ if (commandName === 'help' || args.indexOf('--help') >= 0 || args.indexOf('-h')
process.exit(1);
}

if (!command) {
args.unshift(commandName);
command = commands.run;
}
invariant(command, 'missing command');

// parse flags
args.unshift(commandName);
commander.parse(startArgs.concat(args));
commander.args = commander.args.concat(endArgs);

Expand Down

0 comments on commit 5a55b7d

Please sign in to comment.