Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix: error when command is unknown #2916

Merged
merged 1 commit into from
Mar 13, 2020
Merged

Conversation

achingbrain
Copy link
Member

Since yargs v14, using .parse(command) with an unknown command causes an error to be thrown instead of the help text being printed.

One solution is to use .argv instead of .parse(command) but we use the .parse(command) variant to enable testing as the passed command is evaluated rather than process.argv, which is what happens when you call .argv.

Instead if we detect a error caused by an unknown command, use the parser to show help instead of version of yargs that had .parse(command) called on it.

Since yargs v14, using `.parse(command)` with an unknown command
causes an [error to be thrown](yargs/yargs#1419)
instead of the help text being printed.

One solution is to use `.argv` instead of `.parse(command)` but we
use the `.parse(command)` variant to enable testing as the passed
command is evaluated rather than `process.argv`, which is what happens
when you call `.argv`.

Instead if we detect a error caused by an unknown command, use the parser
to show help instead of version of yargs that had `.parse(command)`
called on it.
@achingbrain achingbrain merged commit 743a7fc into master Mar 13, 2020
@achingbrain achingbrain deleted the fix/error-on-unknown-commands branch March 13, 2020 16:26
mistakia pushed a commit to mistakia/js-ipfs that referenced this pull request Mar 22, 2020
Since yargs v14, using `.parse(command)` with an unknown command
causes an [error to be thrown](yargs/yargs#1419)
instead of the help text being printed.

One solution is to use `.argv` instead of `.parse(command)` but we
use the `.parse(command)` variant to enable testing as the passed
command is evaluated rather than `process.argv`, which is what happens
when you call `.argv`.

Instead if we detect a error caused by an unknown command, use the parser
to show help instead of version of yargs that had `.parse(command)`
called on it.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants