From 0532c1b2a1d982bdef07b3cc849767205466e090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 16 Nov 2021 16:20:39 -0500 Subject: [PATCH] feat: #9957, don't remove existing fields form config.json --- src/install.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/install.js b/src/install.js index 98339c1314..7016662d05 100644 --- a/src/install.js +++ b/src/install.js @@ -527,7 +527,16 @@ install.save = async function (server_conf) { serverConfigPath = path.resolve(__dirname, '../', nconf.get('config')); } - await fs.promises.writeFile(serverConfigPath, JSON.stringify(server_conf, null, 4)); + let currentConfig = {}; + try { + currentConfig = require(serverConfigPath); + } catch (err) { + if (err.code !== 'MODULE_NOT_FOUND') { + throw err; + } + } + + await fs.promises.writeFile(serverConfigPath, JSON.stringify({ ...currentConfig, ...server_conf }, null, 4)); console.log('Configuration Saved OK'); nconf.file({ file: serverConfigPath,