diff options
author | 0neGal <mail@0negal.com> | 2023-01-12 19:33:49 +0100 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2023-01-12 19:34:39 +0100 |
commit | 2889b310c18acc5fbc926d63659a624e4675fe57 (patch) | |
tree | 265bef0435d71d7c0bbc79f05962d7f6e7bf5e95 /src/cli.js | |
parent | a67040498d238c3d7b1b947f7be02034f3b71d52 (diff) | |
download | Viper-2889b310c18acc5fbc926d63659a624e4675fe57.tar.gz Viper-2889b310c18acc5fbc926d63659a624e4675fe57.zip |
added: src/modules/json.js
This module makes it easier to read JSON files, simply returning false
on errors, and attempting to repair the JSON automatically.
Diffstat (limited to 'src/cli.js')
-rw-r--r-- | src/cli.js | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -6,6 +6,7 @@ const events = new Emitter(); const cli = app.commandLine; const lang = require("./lang"); +const json = require("./modules/json"); function hasArgs() { // Makes sure the GUI isn't launched. @@ -38,7 +39,7 @@ function exit(code) { // gamepath to be able to work. function gamepathExists() { if (fs.existsSync("viper.json")) { - gamepath = JSON.parse(fs.readFileSync("viper.json", "utf8")).gamepath; + gamepath = json("viper.json").gamepath; if (! fs.existsSync(gamepath)) { console.error(`error: ${lang("cli.gamepath.lost")}`); |