aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlystrasz <contact@remyraes.com>2021-12-28 23:48:07 +0100
committerAlystrasz <contact@remyraes.com>2021-12-28 23:48:07 +0100
commita4978e160eff00ab387d8217ac53d66ca2794ee3 (patch)
tree84c2a7e61f094b565b437ac4ba7de2946a60dec4
parent78888b8465f833a8dd8ba00d3c34b21ba8dd6cb4 (diff)
downloadViper-a4978e160eff00ab387d8217ac53d66ca2794ee3.tar.gz
Viper-a4978e160eff00ab387d8217ac53d66ca2794ee3.zip
[refactor] northstar version is stored in gamepath
-rw-r--r--src/utils.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/utils.js b/src/utils.js
index 66c8644..dde5515 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -17,7 +17,6 @@ process.chdir(app.getPath("appData"));
var settings = {
gamepath: "",
zip: "/northstar.zip",
- northstar_version: "unknown",
excludes: [
"ns_startup_args.txt",
"ns_startup_args_dedi.txt"
@@ -49,13 +48,21 @@ function setpath(win) {
}
function saveSettings() {
- fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify({...settings}));
+ fs.writeFileSync(app.getPath("appData") + "/viper.json", JSON.stringify(settings));
}
function getInstalledVersion() {
- return JSON.parse(
- fs.readFileSync(app.getPath("appData") + "/viper.json", "utf8")
- )['northstarVersion'];
+ const versionFilePath = path.join(settings.gamepath, 'ns_version.txt');
+
+ if (fs.existsSync(versionFilePath)) {
+ return fs.readFileSync(versionFilePath, "utf8");
+ } else {
+ fs.writeFileSync(versionFilePath, 'unknown');
+ return 'unknown';
+ }
+}
+function updateInstalledVersion(newTag) {
+ fs.writeFileSync(path.join(settings.gamepath, 'ns_version.txt'), newTag);
}
function update() {
@@ -93,8 +100,9 @@ function update() {
fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath}))
.on("finish", () => {
console.log("Installation/Update finished!");
- settings.northstar_version = tag;
- saveSettings();
+
+ updateInstalledVersion(tag);
+
events.emit("updated");
for (let i = 0; i < settings.excludes.length; i++) {