Skip to content
Myr

Merge pull request #573 from tj/revert-503-master

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

Revert "For a required option, when even option flag is not given throw error."

authored by Zhiye Li · committed by GitHub · parents 5b396ab, ce35c35 · Browse files · 3 files+2 added−41 removed
This commit

State

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

Diff stats

3 files+2 added−41 removed

  • tests:+2 added−28 removed
  • other:+0 added−13 removed

3 files+2 added−41 removed

modified:test/test.arguments.js+2 added-2 removed
deleted:test/test.options.args.required.no.given.js-26 removed
modified:index.js-13 removed
374 unmodified lines
375 defaultValue = fn;376 fn = null;377 }378 }379 380 // set default value of the option381 option.defaultValue = defaultValue;379380 // preassign default value only for --no-*, [optional], or <required>381 if (false == option.bool || option.optional || option.required) {382 // when --no-* we make sure default is true
289 unmodified lines
672 , len = argv.length673 , literal674 , option675 , arg;679 680 // if no argv, then check if some required option681 if (len === 0) {682 for (var j = 0, optionLen = this.options.length; j < optionLen; ++j) {683 option = this.options[j];684 if (option.required && option.defaultValue === undefined) {685 return this.optionMissingArgument(option);686 }687 }688 }676677 var unknownOptions = [];678679 // parse options
450 unmodified lines