-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathautoupdate.js
46 lines (42 loc) · 1.36 KB
/
autoupdate.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function getOsName() {
const os = require('os')
if (os.platform() == 'linux') {
if (os.arch() == 'x64') {
return 'Linux64'
} else {
return 'Linux32'
}
} else if (os.platform() == 'win32') {
return 'Windows'
} else if (os.platform() == 'darwin') {
return 'MacOS'
}
return ''
}
const {dialog} = require('electron').remote
const {shell} = require('electron')
const {app} = require('electron').remote
var dialogShowed = false
var currentVersion = app.getVersion()
function checkForUpdates() {
$.getJSON("https://raw.githubusercontent.com/rensa-labs/geph-autoupdate/master/stable.json",
function(data) {
let meta = data[getOsName()]
console.log(meta)
if (meta.Latest != currentVersion && !dialogShowed) {
dialogShowed = true
let dialogOpts = {
type: 'info',
buttons: [l10n["updateDownload"], l10n["updateLater"]],
message: l10n["updateInfo"],
}
dialog.showMessageBox(dialogOpts, (response) => {
if (response === 0) {
shell.openExternal(meta.Mirrors[0])
}
})
}
})
}
console.log("YAY")
setInterval(checkForUpdates, 60 * 60 * 1000)