forked from VRPirates/sidenoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
versioncheck.js
32 lines (29 loc) · 946 Bytes
/
versioncheck.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const pkg = require("./package.json");
const compareVersions = require("compare-versions");
global.version = pkg.version;
async function checkVersion() {
try {
const res = await fetch(
"https://api.github.com/repos/VRPirates/sidenoder/releases/latest",
);
const content = JSON.parse(await res.text());
const remoteversion = content.name;
console.log("Current version: " + pkg.version);
console.log("Github version: " + remoteversion);
if (!remoteversion) return;
if (compareVersions.compare(remoteversion, pkg.version, "<=")) {
console.log("Using latest version");
} else {
console.log("requires update");
win.webContents.send("notify_update", {
success: true,
current: pkg.version,
remote: remoteversion,
url: content.html_url,
description: content.body,
});
}
} catch (err) {
console.error("checkVersion.Fail", err);
}
}