Print a warning on invalid keys in config
This commit is contained in:
parent
2e0100d31c
commit
7c1efb18d1
@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const _ = require("lodash");
|
|
||||||
const log = require("../log");
|
const log = require("../log");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
@ -34,7 +33,7 @@ if (process.getuid) {
|
|||||||
Utils.checkOldHome();
|
Utils.checkOldHome();
|
||||||
|
|
||||||
// Merge config key-values passed as CLI options into the main config
|
// 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");
|
require("./start");
|
||||||
|
|
||||||
|
@ -230,7 +230,11 @@ function getDefaultNick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mergeConfig(oldConfig, newConfig) {
|
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)
|
// 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) {
|
if (typeof objValue !== "undefined" && objValue !== null && typeof objValue !== typeof srcValue) {
|
||||||
log.warn(`Incorrect type for "${colors.bold(key)}", please verify your config.`);
|
log.warn(`Incorrect type for "${colors.bold(key)}", please verify your config.`);
|
||||||
|
Loading…
Reference in New Issue
Block a user