Socket
Socket
Sign inDemoInstall

yargs-parser

Package Overview
Dependencies
1
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.0 to 4.2.0

15

CHANGELOG.md

@@ -5,2 +5,17 @@ # Change Log

<a name="4.2.0"></a>
# [4.2.0](https://github.com/yargs/yargs-parser/compare/v4.1.0...v4.2.0) (2016-12-01)
### Bug Fixes
* inner objects in configs had their keys appended to top-level key when dot-notation was disabled ([#72](https://github.com/yargs/yargs-parser/issues/72)) ([0b1b5f9](https://github.com/yargs/yargs-parser/commit/0b1b5f9))
### Features
* allow multiple arrays to be provided, rather than always combining ([#71](https://github.com/yargs/yargs-parser/issues/71)) ([0f0fb2d](https://github.com/yargs/yargs-parser/commit/0f0fb2d))
<a name="4.1.0"></a>

@@ -7,0 +22,0 @@ # [4.1.0](https://github.com/yargs/yargs-parser/compare/v4.0.2...v4.1.0) (2016-11-07)

27

index.js

@@ -18,3 +18,5 @@ var camelCase = require('camelcase')

'parse-numbers': true,
'boolean-negation': true
'boolean-negation': true,
'duplicate-arguments-array': true,
'flatten-duplicate-arrays': true
}, opts.configuration)

@@ -314,2 +316,4 @@ var defaults = opts.default || {}

var start = i + 1
var argsToSet = []
var multipleArrayFlag = i > 0
for (var ii = i + 1; ii < args.length; ii++) {

@@ -320,7 +324,15 @@ if (/^-/.test(args[ii]) && !negative.test(args[ii])) {

}
multipleArrayFlag = true
break
}
i = ii
setArg(key, args[ii])
argsToSet.push(args[ii])
}
if (multipleArrayFlag && !configuration['flatten-duplicate-arrays']) {
setArg(key, argsToSet)
} else {
argsToSet.forEach(function (arg) {
setArg(key, arg)
})
}

@@ -446,3 +458,6 @@ return i

if (Object.prototype.toString.call(value) === '[object Object]') {
// if the value is an inner object and we have dot-notation
// enabled, treat inner objects in config the same as
// heavily nested dot notations (foo.bar.apple).
if (typeof value === 'object' && !Array.isArray(value) && configuration['dot-notation']) {
// if the value is an object but not an array, check nested object

@@ -546,3 +561,3 @@ setConfigObject(value, fullKey)

} else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) {
o[key] = Array.isArray(value) ? value : [value]
o[key] = Array.isArray(value) && configuration['flatten-duplicate-arrays'] ? value : [value]
} else if (o[key] === undefined || checkAllAliases(key, flags.bools) || checkAllAliases(keys.join('.'), flags.bools) || checkAllAliases(key, flags.counts)) {

@@ -552,4 +567,6 @@ o[key] = value

o[key].push(value)
} else if (configuration['duplicate-arguments-array']) {
o[key] = [ o[key], value ]
} else {
o[key] = [ o[key], value ]
o[key] = value
}

@@ -556,0 +573,0 @@ }

4

package.json
{
"name": "yargs-parser",
"version": "4.1.0",
"version": "4.2.0",
"description": "the mighty option parser used by yargs",

@@ -32,3 +32,3 @@ "main": "index.js",

"mocha": "^3.0.1",
"nyc": "^8.1.0",
"nyc": "^10.0.0",
"standard": "^8.0.0",

@@ -35,0 +35,0 @@ "standard-version": "^3.0.0"

@@ -177,3 +177,3 @@ # yargs-parser

* default: `true`
* key: 'parse-numbers'
* key: `parse-numbers`

@@ -197,3 +197,3 @@ Should keys that look like numbers be treated as such?

* default: `true`
* key: 'boolean-negation'
* key: `boolean-negation`

@@ -214,2 +214,40 @@ Should variables prefixed with `--no` be treated as negations?

### duplicate arguments array
* default: `true`
* key: `duplicate-arguments-array`
Should arguments be coerced into an array when duplicated:
```sh
node example.js -x 1 -x 2
{ _: [], x: [1, 2] }
```
_if disabled:_
```sh
node example.js -x 1 -x 2
{ _: [], x: 2 }
```
### flatten duplicate arrays
* default: `true`
* key: `flatten-duplicate-arrays`
Should array arguments be coerced into a single array when duplicated:
```sh
node example.js -x 1 2 -x 3 4
{ _: [], x: [1, 2, 3, 4] }
```
_if disabled:_
```sh
node example.js -x 1 2 -x 3 4
{ _: [], x: [[1, 2], [3, 4]] }
```
## Special Thanks

@@ -216,0 +254,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc