From 34afacd0d28aa50e48013fadc3f154256b952570 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Mon, 26 Aug 2024 07:38:14 +0200 Subject: [PATCH] Replace "config.json" and "./config.json" with __dirname + "/config.json" in svrpasswd.js --- utils/svrpasswd.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/svrpasswd.js b/utils/svrpasswd.js index 9a66bc9..2f9ba4e 100644 --- a/utils/svrpasswd.js +++ b/utils/svrpasswd.js @@ -255,10 +255,10 @@ if (!crypto.randomInt) { } let configJSON = {}; -if (fs.existsSync("config.json")) { +if (fs.existsSync(__dirname + "/config.json")) { let configJSONf = ""; try { - configJSONf = fs.readFileSync("config.json"); //Read JSON File + configJSONf = fs.readFileSync(__dirname + "/config.json"); //Read JSON File } catch (ex) { throw new Error("Cannot read JSON file."); } @@ -274,11 +274,11 @@ if (configJSON.users != undefined) users = configJSON.users; function saveConfig() { let configJSONobj = {}; - if (fs.existsSync("./config.json")) - configJSONobj = JSON.parse(fs.readFileSync("./config.json").toString()); + if (fs.existsSync(__dirname + "/config.json")) + configJSONobj = JSON.parse(fs.readFileSync(__dirname + "/config.json").toString()); configJSONobj.users = users; const configString = JSON.stringify(configJSONobj, null, 2); - fs.writeFileSync("config.json", configString); + fs.writeFileSync(__dirname + "/config.json", configString); } const args = process.argv;