-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.js
33 lines (32 loc) · 1.16 KB
/
settings.js
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
30
31
32
33
const fs = require("fs");
const mergeJSON = function (target, add) {
function isObject(obj) {
if (typeof obj == "object") {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return true; // search for first object prop
}
}
}
return false;
}
for (var key in add) {
if (add.hasOwnProperty(key)) {
if (key === "__proto__" || key === "constructor") continue;
if (target[key] && isObject(target[key]) && isObject(add[key])) {
mergeJSON(target[key], add[key]);
} else {
target[key] = add[key];
}
}
}
return target;
};
if (!fs.existsSync("./local.settings.json")) {
fs.writeFileSync("./local.settings.json", fs.readFileSync("./settings.json"))
console.log('The file "local.settings.json" has been created, you must fill the parameters.\nSee the documentation on Github for more informations.')
process.exit(0)
}
const settings = require("./settings.json")
const localSettings = require("./local.settings.json")
module.exports = mergeJSON(settings,localSettings)