Skip to content

Commit

Permalink
fail should accept boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed May 2, 2021
1 parent da1f76d commit 0e3c0e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion types/yargs/index.d.ts
Expand Up @@ -333,7 +333,7 @@ declare namespace yargs {
* Method to execute when a failure occurs, rather than printing the failure message.
* @param func Is called with the failure message that would have been printed, the Error instance originally thrown and yargs state when the failure occurred.
*/
fail(func: (msg: string, err: Error, yargs: Argv<T>) => any): Argv<T>;
fail(func: ((msg: string, err: Error, yargs: Argv<T>) => any) | boolean): Argv<T>;

/**
* Allows to programmatically get completion choices for any line.
Expand Down
6 changes: 6 additions & 0 deletions types/yargs/yargs-tests.ts
Expand Up @@ -660,6 +660,12 @@ function Argv$fail() {
process.exit(1);
})
.argv;

// Providing false as a value for fn can be used to prevent yargs from
// exiting and printing a failure message
const ya2 = yargs
.fail(false)
.argv;
}

function Argv$implies() {
Expand Down

0 comments on commit 0e3c0e8

Please sign in to comment.