From 70b2636baffdce346b3250dea1b3a9564dd03f3e Mon Sep 17 00:00:00 2001 From: laggingreflex Date: Sat, 12 Nov 2016 20:34:11 +0530 Subject: [PATCH] feat: allow disabling duplicate-arguments-array 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} ``` --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 0d3ed26a..46a3fa18 100644 --- a/index.js +++ b/index.js @@ -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 || [] @@ -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 } }