Skip to content

Commit

Permalink
feat: allow disabling duplicate-arguments-array
Browse files Browse the repository at this point in the history
Lets you disable "duplicates" behaviour

```
yargsParser('-x 1 -x 2')
// => {x: [1, 2]}
```
```
yargsParser('-x 1 -x 2', {configuration:{'duplicate-arguments-array': false}})
// => {x: 2}
```
  • Loading branch information
laggingreflex committed Nov 12, 2016
1 parent a491feb commit 70b2636
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Expand Up @@ -15,7 +15,8 @@ function parse (args, opts) {
'camel-case-expansion': true,
'dot-notation': true,
'parse-numbers': true,
'boolean-negation': true
'boolean-negation': true,
'duplicate-arguments-array': true
}, opts.configuration)
var defaults = opts.default || {}
var configObjects = opts.configObjects || []
Expand Down Expand Up @@ -544,8 +545,10 @@ function parse (args, opts) {
o[key] = value
} else if (Array.isArray(o[key])) {
o[key].push(value)
} else {
} else if (configuration['duplicate-arguments-array']) {
o[key] = [ o[key], value ]
} else {
o[key] = value
}
}

Expand Down

0 comments on commit 70b2636

Please sign in to comment.