forked from svrjs/svrjs
Replace "config.json" and "./config.json" with __dirname + "/config.json" in svrpasswd.js
This commit is contained in:
parent
7133e750cc
commit
34afacd0d2
1 changed files with 5 additions and 5 deletions
|
@ -255,10 +255,10 @@ if (!crypto.randomInt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let configJSON = {};
|
let configJSON = {};
|
||||||
if (fs.existsSync("config.json")) {
|
if (fs.existsSync(__dirname + "/config.json")) {
|
||||||
let configJSONf = "";
|
let configJSONf = "";
|
||||||
try {
|
try {
|
||||||
configJSONf = fs.readFileSync("config.json"); //Read JSON File
|
configJSONf = fs.readFileSync(__dirname + "/config.json"); //Read JSON File
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
throw new Error("Cannot read JSON file.");
|
throw new Error("Cannot read JSON file.");
|
||||||
}
|
}
|
||||||
|
@ -274,11 +274,11 @@ if (configJSON.users != undefined) users = configJSON.users;
|
||||||
|
|
||||||
function saveConfig() {
|
function saveConfig() {
|
||||||
let configJSONobj = {};
|
let configJSONobj = {};
|
||||||
if (fs.existsSync("./config.json"))
|
if (fs.existsSync(__dirname + "/config.json"))
|
||||||
configJSONobj = JSON.parse(fs.readFileSync("./config.json").toString());
|
configJSONobj = JSON.parse(fs.readFileSync(__dirname + "/config.json").toString());
|
||||||
configJSONobj.users = users;
|
configJSONobj.users = users;
|
||||||
const configString = JSON.stringify(configJSONobj, null, 2);
|
const configString = JSON.stringify(configJSONobj, null, 2);
|
||||||
fs.writeFileSync("config.json", configString);
|
fs.writeFileSync(__dirname + "/config.json", configString);
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = process.argv;
|
const args = process.argv;
|
||||||
|
|
Reference in a new issue