mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #6 from overleaf/jpa-export-merge
[misc] expose merge function in a separate module
This commit is contained in:
commit
81f4c31208
3 changed files with 14 additions and 12 deletions
|
@ -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");
|
||||
|
||||
|
|
12
libraries/settings/merge.js
Normal file
12
libraries/settings/merge.js
Normal 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 };
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue