mirror of
https://github.com/Retropex/umbrel-bitcoin.git
synced 2025-05-12 03:00:49 +02:00
use lodash.merge instead of spread operator when merging settings to future proof
Co-authored-by: Luke Childs <lukechilds123@gmail.com>
This commit is contained in:
parent
ffc72ec7f4
commit
75c837c4b0
@ -1,4 +1,5 @@
|
||||
const fs = require("fs");
|
||||
const merge = require('lodash.merge');
|
||||
|
||||
const path = require("path");
|
||||
const constants = require("utils/const.js");
|
||||
const diskService = require("services/disk");
|
||||
@ -27,7 +28,7 @@ const DEFAULT_ADVANCED_SETTINGS = {
|
||||
async function getJsonStore() {
|
||||
try {
|
||||
const jsonStore = await diskService.readJsonFile(constants.JSON_STORE_FILE);
|
||||
return { ...DEFAULT_ADVANCED_SETTINGS, ...jsonStore };
|
||||
return merge({}, DEFAULT_ADVANCED_SETTINGS, jsonStore);
|
||||
} catch (error) {
|
||||
return DEFAULT_ADVANCED_SETTINGS;
|
||||
}
|
||||
@ -52,10 +53,7 @@ async function applyBitcoinConfig(bitcoinConfig, shouldOverwriteExistingFile) {
|
||||
// There's a race condition here if you do two updates in parallel but it's fine for our current use case
|
||||
async function updateJsonStore(newProps) {
|
||||
const jsonStore = await getJsonStore();
|
||||
return diskService.writeJsonFile(constants.JSON_STORE_FILE, {
|
||||
...jsonStore,
|
||||
...newProps
|
||||
});
|
||||
return diskService.writeJsonFile(constants.JSON_STORE_FILE, merge(jsonStore, newProps));
|
||||
}
|
||||
|
||||
// creates umbrel-bitcoin.conf
|
||||
|
@ -24,6 +24,7 @@
|
||||
"debug": "^2.6.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.16.3",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"module-alias": "^2.1.0",
|
||||
"morgan": "^1.9.0",
|
||||
"request-promise": "^4.2.2",
|
||||
|
@ -1683,6 +1683,11 @@ lodash.get@^4.4.2:
|
||||
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
|
||||
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
|
||||
|
||||
lodash.merge@^4.6.2:
|
||||
version "4.6.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
|
||||
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
|
||||
|
||||
lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.5, lodash@^4.2.0:
|
||||
version "4.17.21"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||
|
Loading…
Reference in New Issue
Block a user