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 adding package with name like one of the options #2268

Merged
merged 1 commit into from
Dec 18, 2016
Merged

Fix adding package with name like one of the options #2268

merged 1 commit into from
Dec 18, 2016

Conversation

iredchuk
Copy link
Contributor

@iredchuk iredchuk commented Dec 15, 2016

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.

@torifat
Copy link
Member

torifat commented Dec 18, 2016

@iredchuk does it work with global? Can you add test cases for yarn global <command>?

@iredchuk
Copy link
Contributor Author

@torifat Sure, added

@torifat
Copy link
Member

torifat commented Dec 18, 2016

@iredchuk weird, test failing. Can you please rebase and push again?

@iredchuk
Copy link
Contributor Author

@torifat My bad: the test for global was conflicting with another one when running concurrently. Should be fixed now.

@torifat
Copy link
Member

torifat commented Dec 18, 2016

@iredchuk Ah, Thanks 👍

@torifat torifat merged commit 6972396 into yarnpkg:master Dec 18, 2016
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants