-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 adding package with name like one of the options #2268
Merged
torifat
merged 1 commit into
yarnpkg:master
from
iredchuk:fix-add-package-with-name-like-an-option
Dec 18, 2016
Merged
Fix adding package with name like one of the options #2268
torifat
merged 1 commit into
yarnpkg:master
from
iredchuk:fix-add-package-with-name-like-an-option
Dec 18, 2016
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@iredchuk does it work with global? Can you add test cases for |
@iredchuk weird, test failing. Can you please rebase and push again? |
@torifat My bad: the test for global was conflicting with another one when running concurrently. Should be fixed now. |
@iredchuk Ah, Thanks 👍 |
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 20, 2017
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. This relates to PR yarnpkg#2268.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 20, 2017
…ease 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. This relates to PR yarnpkg#2268.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 20, 2017
…rnpkg#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. This relates to PR yarnpkg#2268.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 20, 2017
…g#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. This relates to PR yarnpkg#2268.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 20, 2017
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. This relates to PR yarnpkg#2268.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 20, 2017
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.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 20, 2017
…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.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 25, 2017
…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.
ConAntonakos
pushed a commit
to ConAntonakos/yarn
that referenced
this pull request
Jan 30, 2017
…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.
bestander
pushed a commit
that referenced
this pull request
Feb 1, 2017
… (#2510) * Fix `yarn version` which yields same output as `yarn --version` (#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 #2268. * Shift first arg that shares name with an option to circumvent conflicting name bug Relating to tj/commander.js#346, when an arg shares the same name as an option, it wrongly ignores the arg command and executes the option instead. Therefore, executing 'yarn version' would instead translate to 'yarn --version'. This logic can subsequently be removed once this issue is resolved.
bestander
pushed a commit
that referenced
this pull request
Feb 1, 2017
… (#2510) * Fix `yarn version` which yields same output as `yarn --version` (#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 #2268. * Shift first arg that shares name with an option to circumvent conflicting name bug Relating to tj/commander.js#346, when an arg shares the same name as an option, it wrongly ignores the arg command and executes the option instead. Therefore, executing 'yarn version' would instead translate to 'yarn --version'. This logic can subsequently be removed once this issue is resolved.
bestander
pushed a commit
that referenced
this pull request
Feb 1, 2017
… (#2510) * Fix `yarn version` which yields same output as `yarn --version` (#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 #2268. * Shift first arg that shares name with an option to circumvent conflicting name bug Relating to tj/commander.js#346, when an arg shares the same name as an option, it wrongly ignores the arg command and executes the option instead. Therefore, executing 'yarn version' would instead translate to 'yarn --version'. This logic can subsequently be removed once this issue is resolved.
mnsn
pushed a commit
to mnsn/yarn
that referenced
this pull request
Feb 15, 2017
…pkg#2491) (yarnpkg#2510) * Fix `yarn version` which yields same output as `yarn --version` (yarnpkg#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. * Shift first arg that shares name with an option to circumvent conflicting name bug Relating to tj/commander.js#346, when an arg shares the same name as an option, it wrongly ignores the arg command and executes the option instead. Therefore, executing 'yarn version' would instead translate to 'yarn --version'. This logic can subsequently be removed once this issue is resolved.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes issue when yarn cannot add/remove package which name is equal to one of the CLI options (e.g. lockfile, progress).
Fixes issue #2112.
The source of the error is this bug from commander.js: tj/commander.js#346
when the first argument after the first two process.agrvs (i.e. node yarn) cannot have the same name as options defined with commander.
The solution is to parse args along with the command name and the remove command name from the args.
$ yarn add lockfile
should work correctly
I added basic integration tests, but IMO would probably be nicer to extract the whole arguments parsing to a separate module and unit test it more intensively, but I found it pretty hard with the current implementation. This might be done later on a separate improvement PR.