Skip to content

Bug: .check ignored when .command is specified and complied with #762

Description

@giacecco

I'm using version 6.6.0. The code below intentionally triggers an error:

var argv = require('yargs')
    .check((argv, opts) => { throw(new Error("Error!")); return false; })
    .argv;
console.log("Hello world!");
$ node test.js

Error!
$ 

... but if I add a .command directive, it does not:

var argv = require('yargs')
    .command("foo")
    .check((argv, opts) => { throw(new Error("Error!")); return false; })
    .argv;
console.log("Hello world!");
$ node test.js foo
Hello world!
$ 

Oddly enough, if I don't provide the specified command, then .check works again:

$ node test.js bar
Commands:
  foo

Error!
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions