From 52b0e87e76c7acefada52b7b8af15eaae5483fbe Mon Sep 17 00:00:00 2001 From: juergba Date: Fri, 12 Jul 2019 09:01:02 +0200 Subject: [PATCH] process values of number[] --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4fd05531..11eac1e5 100644 --- a/index.js +++ b/index.js @@ -470,7 +470,9 @@ function parse (args, opts) { if (typeof val === 'string') val = val === 'true' } - var value = maybeCoerceNumber(key, val) + var value = Array.isArray(val) + ? val.map(function (v) { return maybeCoerceNumber(key, v) }) + : maybeCoerceNumber(key, val) // increment a count given as arg (either no value or value parsed as boolean) if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) { @@ -486,7 +488,7 @@ function parse (args, opts) { } function maybeCoerceNumber (key, value) { - if (!checkAllAliases(key, flags.strings)) { + if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) { const shouldCoerceNumber = isNumber(value) && configuration['parse-numbers'] && ( Number.isSafeInteger(Math.floor(value)) )