forked from boltgolt/boltobserv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadconfig.js
More file actions
29 lines (23 loc) · 795 Bytes
/
loadconfig.js
File metadata and controls
29 lines (23 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require("fs")
const JSON5 = require("json5")
const path = require("path")
const util = require("util")
let cachedConfig = false
module.exports = () => {
if (cachedConfig !== false) return cachedConfig
let loadedConfig = JSON5.parse(fs.readFileSync(path.join(__dirname, "config", "config.json5"), "utf8"))
if (fs.existsSync(path.join(__dirname, "config", "config.override.json5"))) {
let override = JSON5.parse(fs.readFileSync(path.join(__dirname, "config", "config.override.json5"), "utf8"))
Object.assign(loadedConfig, override)
}
if (loadedConfig.debug.printConfig) {
console.info("Loaded config:", util.inspect(loadedConfig, {
showHidden: true,
depth: Infinity,
colors: true,
compact: false
}))
}
cachedConfig = loadedConfig
return loadedConfig
}