I checked here first before I come here. My question is a little different than that. I have following folder structure.
- app.js
- global.config.js
- node-modules
- my module
- module.config.js
- index.js
- my module
global.config.js:
var config = {};
config.loggingLevel: "error"; // global setting for all custom modules
module.config.js:
var config = {};
config.loggingLevel: "info"; // ideally should override global setting
index.js
var globalDir = path.dirname(require.main.filename) + "\\global.config.js";
var globalConfig = require(globalDir);
var moduleConfig = require("./module.config.js");
// merge configs here and use only one config object
As seen here, I have a global and module specific config files. I would like to merge them into one config file and use that way.
Is there any way to achieve this easily? (Like a pre-written module) Or should I iterate through each property and override if same key exists?