aboutsummaryrefslogtreecommitdiff
path: root/src/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.js')
-rw-r--r--src/utils.js48
1 files changed, 38 insertions, 10 deletions
diff --git a/src/utils.js b/src/utils.js
index c4318d0..7139706 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -220,21 +220,49 @@ function saveSettings(obj = {}) {
// Returns the current Northstar version
// If not installed it'll return "unknown"
function getNSVersion() {
- var versionFile = path.join(settings.gamepath, "R2Northstar/mods/Northstar.Client/mod.json");
+ var versionFiles = [
+ "Northstar.Client",
+ "Northstar.Custom",
+ "Northstar.CustomServers"
+ ]
+
+ var versions = [];
+
+
+ let add = (version) => {
+ versions.push(version)
+ }
+
+ for (let i = 0; i < versionFiles.length; i++) {
+ var versionFile = path.join(settings.gamepath, "R2Northstar/mods/", versionFiles[i],"/mod.json");
+ if (fs.existsSync(versionFile)) {
+ if (! fs.statSync(versionFile).isFile()) {
+ add("unknown");
+ }
- if (fs.existsSync(versionFile)) {
- if (! fs.statSync(versionFile).isFile()) {
- return "unknown"
+ try {
+ add("v" + JSON.parse(fs.readFileSync(versionFile, "utf8")).Version);
+ }catch(err) {
+ add("unknown");
+ }
+ } else {
+ add("unknown");
}
+ }
+
+ if (versions.includes("unknown")) {return "unknown"}
- try {
- return "v" + JSON.parse(fs.readFileSync(versionFile, "utf8")).Version;
- }catch(err) {
- return "unknown";
+ let mismatch = false;
+ let baseVersion = versions[0];
+ for (let i = 0; i < versions.length; i++) {
+ if (versions[i] != baseVersion) {
+ mismatch = true;
+ break
}
- } else {
- return "unknown";
}
+
+ if (mismatch) {return "unknown"}
+ return baseVersion;
}