From 7c1efb18d161a912e3d0b64d40eeb46823b97194 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Mon, 4 Mar 2019 20:35:21 +0200 Subject: [PATCH] Print a warning on invalid keys in config --- src/command-line/index.js | 3 +-- src/helper.js | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/command-line/index.js b/src/command-line/index.js index 107a1450..b45c7ced 100644 --- a/src/command-line/index.js +++ b/src/command-line/index.js @@ -1,6 +1,5 @@ "use strict"; -const _ = require("lodash"); const log = require("../log"); const fs = require("fs"); const path = require("path"); @@ -34,7 +33,7 @@ if (process.getuid) { Utils.checkOldHome(); // Merge config key-values passed as CLI options into the main config -_.merge(Helper.config, program.config); +Helper.mergeConfig(Helper.config, program.config); require("./start"); diff --git a/src/helper.js b/src/helper.js index 5874db7a..d2f96f51 100644 --- a/src/helper.js +++ b/src/helper.js @@ -230,7 +230,11 @@ function getDefaultNick() { } function mergeConfig(oldConfig, newConfig) { - return _.mergeWith(oldConfig, newConfig, (objValue, srcValue, key) => { + return _.mergeWith(oldConfig, newConfig, (objValue, srcValue, key, object) => { + if (!object.hasOwnProperty(key)) { + log.warn(`Unknown key "${colors.bold(key)}", please verify your config.`); + } + // Do not override config variables if the type is incorrect (e.g. object changed into a string) if (typeof objValue !== "undefined" && objValue !== null && typeof objValue !== typeof srcValue) { log.warn(`Incorrect type for "${colors.bold(key)}", please verify your config.`);