[misc] expose merge function in a separate module

This commit is contained in:
Jakob Ackermann 2021-07-06 13:51:28 +01:00
parent 955c9162c0
commit 03f6e8af64
3 changed files with 14 additions and 12 deletions

View file

@ -2,17 +2,7 @@ let defaults, possibleConfigFiles, settingsExist;
const fs = require("fs");
const path = require("path");
const env = (process.env.NODE_ENV || "development").toLowerCase();
const merge = function(settings, defaults) {
for (const [key, value] of Object.entries(settings)) {
if ((typeof(value) === "object") && !(value instanceof Array)) {
defaults[key] = merge(value, defaults[key] || {});
} else {
defaults[key] = value;
}
}
return defaults;
};
const { merge } = require('./merge');
const defaultSettingsPath = path.normalize(__dirname + "/../../config/settings.defaults");

View file

@ -0,0 +1,12 @@
function merge(settings, defaults) {
for (const [key, value] of Object.entries(settings)) {
if ((typeof(value) === "object") && !(value instanceof Array)) {
defaults[key] = merge(value, defaults[key] || {});
} else {
defaults[key] = value;
}
}
return defaults;
}
module.exports = { merge };

View file

@ -1,6 +1,6 @@
{
"name": "@overleaf/settings",
"description": "A centralised settings system for Overleaf",
"version": "2.0.0",
"version": "2.1.0",
"repository": "overleaf/settings-module"
}