aboutsummaryrefslogtreecommitdiff
path: root/src/cli.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-01-12 19:33:49 +0100
committer0neGal <mail@0negal.com>2023-01-12 19:34:39 +0100
commit2889b310c18acc5fbc926d63659a624e4675fe57 (patch)
tree265bef0435d71d7c0bbc79f05962d7f6e7bf5e95 /src/cli.js
parenta67040498d238c3d7b1b947f7be02034f3b71d52 (diff)
downloadViper-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.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cli.js b/src/cli.js
index 95887f7..affcd9e 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -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")}`);