diff options
author | 0neGal <mail@0negal.com> | 2022-05-03 15:33:54 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2022-05-03 15:36:49 +0200 |
commit | ed99ebe06d4b7141ec5452fd792c8bd3b7722234 (patch) | |
tree | 8b9bf3890e8833bb077323838e60434105e10441 /src/utils.js | |
parent | 5426a3182395eb0ab6bd4e02b67cef1df9af6ced (diff) | |
download | Viper-ed99ebe06d4b7141ec5452fd792c8bd3b7722234.tar.gz Viper-ed99ebe06d4b7141ec5452fd792c8bd3b7722234.zip |
fixed various errors when reading modfile
Diffstat (limited to 'src/utils.js')
-rw-r--r-- | src/utils.js | 10 |
1 files changed, 5 insertions, 5 deletions
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]) { |