forked from yargs/yargs
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: accept single function for middleware
* Fixed type check in .middleware() method `if (typeof callback === 'object')` should be `if (typeof callback === 'function')` See Issue yargs#1214 for details * middewareFactory accepts a function, not an object According to [the docs for the `.middleware()` method](http://yargs.js.org/docs/#api-middlewarecallbacks): > The `callbacks` parameter can be a function or a list of functions See Issue yargs#1214 for more details * Added/Updated middleware tests I added a new test to verify that the `.middleware()` method works when a single function is passed, rather than an array of functions. Also enhanced an existing test to ensure that _all_ middleware is run before commands, regardless of whether it was added as an array of functions or a single function.
- Loading branch information
1 parent
6c6c27d
commit 66fd6f7
Showing
2 changed files
with
33 additions
and
8 deletions.
There are no files selected for viewing
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
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