Skip to content
Myr

Merge branch 'integration'

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

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parents 3fb7ab0, c0b42f5 · Browse files · 3 files+64 added−9 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+64 added−9 removed

  • tests:+46 added−0 removed
  • other:+18 added−9 removed

3 files+64 added−9 removed

modified:lib/commander.js+18 added-9 removed
264 unmodified lines
265266 // default as 3rd arg267 if ('function' != typeof fn) defaultValue = fn, fn = null;268269 // preassign default value only for --no-*, [optional], or <required>270 if (false == option.bool || option.optional || option.required) {269 // when --no-* we default to true270 if (false == option.bool) defaultValue = true;271 // when --no-* we make sure default is true272 if (false == option.bool) defaultValue = true;273 // preassign only if we have a default274 if (undefined !== defaultValue) self[name] = defaultValue;275 }276272 // default273 if (undefined !== defaultValue) self[name] = defaultValue;274277 // register the option278 this.options.push(option);279280 // when it's passed assign the value
1 unmodified line
282 this.on(name, function(val){283 // coercion284 if (null != val && fn) val = fn(val);285284 // assign value285 self[name] = null == val286 ? option.bool287 : val;286 // unassigned or bool287 if (/undefined|boolean/.test(typeof self[name])) {288 // if no value, bool true, and we have a default, then use it!289 self[name] = null == val290 ? (option.bool291 ? defaultValue || true : false292 ) : val;293 } else {294 // reassign295 self[name] = val;296 }297 });298299 return this;300};
602 unmodified lines
added:test/test.options.defaults.given.js+23 added
added:test/test.options.defaults.js+23 added