-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.js
30 lines (28 loc) · 1.03 KB
/
update.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
/* global fs, http, vm */
(function () {
const server = "https://gdi.sh/version/";
http.get(server + vm.arch, function (data, code) {
if (code !== 200) {
console.log("-- unable to access gdi.js server");
return;
}
console.log(data);
if (data.latest > vm.version) {
console.log("-- downloading v" + data.latest);
var local = vm.path["temp"] + extractFileName(data.src);
http.download(data.src, local, function (e) {
if (e && e.result === true) {
var installer = fs.run(local);
console.log(installer);
if (installer >= 1) {
vm.terminate();
}
} else {
console.log("l-- unable to download installer, please visit https://gdi.sh to get latest version");
}
});
} else {
console.log("-- gdi.js up to date");
}
});
})();