Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yargs-parser

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yargs-parser - npm Package Compare versions

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] || {})

12

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc