From 048399d90d3e930296fd59be248b6149f22d575b Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sun, 27 Mar 2016 00:37:59 +0800 Subject: [PATCH] simplify parseJSONOption --- cli.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cli.js b/cli.js index 62cfce5..1abdd98 100755 --- a/cli.js +++ b/cli.js @@ -137,13 +137,12 @@ cli.main(function(args, options) { } } - function parseJSONOption(value, options) { - var opts = options || {}; + function parseJSONOption(value, regexArray) { if (value !== null) { var jsonArray; try { jsonArray = JSON.parse(value); - if (opts.regexArray) { + if (regexArray) { jsonArray = jsonArray.map(function (regexString) { return stringToRegExp(regexString); }); @@ -266,13 +265,13 @@ cli.main(function(args, options) { mainOptionKeys.forEach(function(key) { var paramKey = changeCase.paramCase(key); var value = options[paramKey]; - if (options[paramKey] !== null) { + if (value !== null) { switch (mainOptions[key][1]) { case 'json': minifyOptions[key] = parseJSONOption(value); break; case 'json-regex': - minifyOptions[key] = parseJSONOption(value, { regexArray: true }); + minifyOptions[key] = parseJSONOption(value, true); break; case 'string-regex': minifyOptions[key] = stringToRegExp(value); -- 2.34.1