From 1da0c43f5d15ea93aa9de276dc0b5b803492bcf8 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Sat, 11 Dec 2021 15:03:04 +0100 Subject: [PATCH] Allow overriding boolean config values again. #12 --- index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/index.js b/index.js index 0bd3b63..0e8cf8d 100644 --- a/index.js +++ b/index.js @@ -24,6 +24,8 @@ let verbose = false; let schemaMap = {}; let schemaFolder = null; +let booleanArgs = ['verbose', 'ignoreCerts', 'lint', 'format', 'version']; + async function run(config) { try { let args = config || minimist(process.argv.slice(2)); @@ -60,6 +62,14 @@ async function run(config) { if (key === '_' && Array.isArray(value) && value.length > 0) { config.files = value; } + else if (booleanArgs.includes(key)) { + if (typeof value === 'string' && value.toLowerCase() === 'false') { + config[key] = false; + } + else { + config[key] = Boolean(value); + } + } else { config[key] = value; }