yargs-parser
Advanced tools
Comparing version 2.1.1 to 2.1.2
11
index.js
@@ -297,4 +297,10 @@ var assign = require('lodash.assign') | ||
function eatArray (i, key, args) { | ||
var start = i + 1 | ||
for (var ii = i + 1; ii < args.length; ii++) { | ||
if (/^-/.test(args[ii])) break | ||
if (/^-/.test(args[ii])) { | ||
if (ii === start) { | ||
setArg(key, defaultForType('array')) | ||
} | ||
break | ||
} | ||
i = ii | ||
@@ -448,2 +454,5 @@ setArg(key, args[ii]) | ||
var o = obj | ||
if (!configuration['dot-notation']) keys = [keys.join('.')] | ||
keys.slice(0, -1).forEach(function (key) { | ||
@@ -450,0 +459,0 @@ o = (o[key] || {}) |
{ | ||
"name": "yargs-parser", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "the mighty option parser used by yargs", | ||
@@ -29,11 +29,11 @@ "main": "index.js", | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.11.6", | ||
"coveralls": "^2.11.8", | ||
"mocha": "^2.4.5", | ||
"nyc": "^5.6.0", | ||
"standard": "^5.4.1" | ||
"nyc": "^6.1.1", | ||
"standard": "^6.0.8" | ||
}, | ||
"dependencies": { | ||
"camelcase": "^2.1.0", | ||
"lodash.assign": "^4.0.2" | ||
"camelcase": "^2.1.1", | ||
"lodash.assign": "^4.0.6" | ||
} | ||
} |
@@ -1127,2 +1127,16 @@ /* global beforeEach, describe, it */ | ||
it('should default an array to an empty array if passed as first option followed by another', function () { | ||
var result = parser(['-a', '-b'], { | ||
array: 'a' | ||
}) | ||
result.should.have.property('a').and.deep.equal([]) | ||
}) | ||
it('should not attempt to default array if an element has already been populated', function () { | ||
var result = parser(['-a', 'foo', 'bar', '-b'], { | ||
array: 'a' | ||
}) | ||
result.should.have.property('a').and.deep.equal(['foo', 'bar']) | ||
}) | ||
it('should default argument to empty array if no value given', function () { | ||
@@ -1132,3 +1146,3 @@ var result = parser(['-b'], { | ||
}) | ||
Array.isArray(result.b).should.equal(true) | ||
result.should.have.property('b').and.deep.equal([]) | ||
}) | ||
@@ -1522,2 +1536,31 @@ | ||
}) | ||
it('should use value from cli, if cli overrides dot notation default', function () { | ||
var parsed = parser(['--foo.bar', 'abc'], { | ||
default: { | ||
'foo.bar': 'default' | ||
}, | ||
configuration: { | ||
'dot-notation': false | ||
} | ||
}) | ||
expect(parsed['foo.bar']).to.equal('abc') | ||
}) | ||
it('should also override dot notation alias', function () { | ||
var parsed = parser(['--foo.bar', 'abc'], { | ||
alias: { | ||
'foo.bar': ['alias.bar'] | ||
}, | ||
default: { | ||
'foo.bar': 'default' | ||
}, | ||
configuration: { | ||
'dot-notation': false | ||
} | ||
}) | ||
expect(parsed['alias.bar']).to.equal('abc') | ||
}) | ||
}) | ||
@@ -1524,0 +1567,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76744
2016
Updatedcamelcase@^2.1.1
Updatedlodash.assign@^4.0.6