Skip to content
Myr

if args is falsy, assume a default collection.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This is kind of an edge case. When the command's option is not required, and the option is not optional, and we follow the ``` * program * .command(..) * .description(..) * .action(function(){ * }); ``` pattern, then after some event chaining args happens to be `undefined` which breaks the flow. Providing a default value if args do not exist, will make the function less error-prone nonetheless; and it won't cause any regression in the existing behavior.

authored by Volkan Ozcelik · committed by Volkan Ozcelik · parent 534c63a · Browse files · 1 file+2 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−0 removed

  • other:+2 added−0 removed

1 file+2 added−0 removed

modified:index.js+2 added
213 unmodified lines
214Command.prototype.action = function(fn){215 var self = this;216 this.parent.on(this._name, function(args, unknown){217 // Parse any so-far unknown options218 args = args || [];219 unknown = unknown || [];220221 var parsed = self.parseOptions(unknown);222223 // Output help if necessary224 outputHelpIfNecessary(self, parsed.unknown);
630 unmodified lines