aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2022-05-24 15:21:32 +0200
committer0neGal <mail@0negal.com>2022-05-24 15:21:32 +0200
commit91a6f7161865b4b405e7c5517113d8e519c15aaf (patch)
tree1e7b38a368bf71bd04567c13d4d1dde2cc9b2af9
parent0f9d80cce91960350c42a50cbbee0a8d4e0c8713 (diff)
downloadViper-91a6f7161865b4b405e7c5517113d8e519c15aaf.tar.gz
Viper-91a6f7161865b4b405e7c5517113d8e519c15aaf.zip
deprecate ns_version.txt
-rw-r--r--src/utils.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/utils.js b/src/utils.js
index e63297e..c4318d0 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -220,15 +220,19 @@ function saveSettings(obj = {}) {
// Returns the current Northstar version
// If not installed it'll return "unknown"
function getNSVersion() {
- var versionFilePath = path.join(settings.gamepath, "ns_version.txt");
+ var versionFile = path.join(settings.gamepath, "R2Northstar/mods/Northstar.Client/mod.json");
- if (fs.existsSync(versionFilePath)) {
- return fs.readFileSync(versionFilePath, "utf8");
- } else {
- if (gamepathExists()) {
- fs.writeFileSync(versionFilePath, "unknown");
+ if (fs.existsSync(versionFile)) {
+ if (! fs.statSync(versionFile).isFile()) {
+ return "unknown"
}
+ try {
+ return "v" + JSON.parse(fs.readFileSync(versionFile, "utf8")).Version;
+ }catch(err) {
+ return "unknown";
+ }
+ } else {
return "unknown";
}
}
@@ -278,6 +282,7 @@ async function update() {
var version = getNSVersion();
const latestAvailableVersion = await requests.getLatestNsVersion();
+ console.log(latestAvailableVersion)
// Makes sure it is not already the latest version
if (version === latestAvailableVersion) {
@@ -325,7 +330,6 @@ async function update() {
// installing Northstar.
fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath}))
.on("finish", () => {
- fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), latestAvailableVersion);
ipcMain.emit("getversion");
restoreExcludedFiles();