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

Handle name conflict for --version option #713

Merged
merged 1 commit into from Sep 12, 2019
Merged

Handle name conflict for --version option #713

merged 1 commit into from Sep 12, 2019

Conversation

draperunner
Copy link
Contributor

Summary:

Fixes #711

The global --version option wouldn't print anything. That's because the name version conflicts with the built-in commander method commander.version(). Therefore, when calling commander.version, it wouldn't understand that it should use our --version option.

Here's an issue on commander that explains the same issue: tj/commander.js#1020

I have fixed this by checking if the raw arguments contain the --version argument. Even though sub-commands like init has a different --version parameter, this check is safe because of the existing check on commander.args.length === 0. The global --version option will only be used if no sub-command is used.

Test Plan:

Before applying the changes, I ran node packages/cli --version and saw that it printed nothing.
After applying the changes, I ran the same command and saw that it returned the version stated in package.json.

@Esemesek Esemesek merged commit 7bf983b into react-native-community:master Sep 12, 2019
@draperunner draperunner deleted the fix-version-option branch September 12, 2019 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--version prints nothing on RN 0.60
2 participants