qortal-ui/config/config.js

33 lines
642 B
JavaScript
Raw Permalink Normal View History

2021-12-25 14:39:47 +01:00
let config = require('./default.config.js')
2021-12-25 14:39:47 +01:00
let userConfig = {}
2021-12-25 14:39:47 +01:00
try {
userConfig = require('./customConfig.js')
2021-12-25 14:39:47 +01:00
} catch (e) {
console.warn(e)
console.warn('Error loading user config')
2021-12-25 14:39:47 +01:00
}
2021-12-25 14:39:47 +01:00
const checkKeys = (storeObj, newObj) => {
for (const key in newObj) {
if (!Object.prototype.hasOwnProperty.call(storeObj, key)) {
return
}
if (typeof newObj[key] === 'object') {
storeObj[key] = checkKeys(storeObj[key], newObj[key])
} else {
storeObj[key] = newObj[key]
}
}
2021-12-25 14:39:47 +01:00
return storeObj
2021-12-25 14:39:47 +01:00
}
const getConfig = customConfig => {
config = checkKeys(config, customConfig)
return config
2021-12-25 14:39:47 +01:00
}
module.exports = getConfig(userConfig)