From ed99ebe06d4b7141ec5452fd792c8bd3b7722234 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 3 May 2022 15:33:54 +0200 Subject: fixed various errors when reading modfile --- src/utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/utils.js b/src/utils.js index 4afbb2b..eb9f195 100644 --- a/src/utils.js +++ b/src/utils.js @@ -428,7 +428,7 @@ const mods = { let disabled = []; if (! fs.existsSync(modpath)) { - fs.mkdirSync(path.join(modpath, "disabled"), {recursive: true}) + fs.mkdirSync(path.join(modpath), {recursive: true}) return { enabled: [], disabled: [], @@ -531,17 +531,17 @@ const mods = { fs.writeFileSync(file, JSON.stringify(names)) }, disable: (mod) => { - let data = require(file); + let data = JSON.parse(repair(fs.readFileSync(file, "utf8"))); data[mod] = false; fs.writeFileSync(file, JSON.stringify(data)); }, enable: (mod) => { - let data = require(file); + let data = JSON.parse(repair(fs.readFileSync(file, "utf8"))); data[mod] = true; fs.writeFileSync(file, JSON.stringify(data)); }, toggle: (mod) => { - let data = require(file); + let data = JSON.parse(repair(fs.readFileSync(file, "utf8"))); if (data[mod] != undefined) { data[mod] = ! data[mod]; } else { @@ -551,7 +551,7 @@ const mods = { fs.writeFileSync(file, JSON.stringify(data)); }, get: (mod) => { - let data = require(file); + let data = JSON.parse(repair(fs.readFileSync(file, "utf8"))); let names = Object.keys(data); if (data[mod]) { -- cgit v1.2.3