aboutsummaryrefslogtreecommitdiff
path: root/src/utils.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2021-12-30 19:19:16 +0100
committerGitHub <noreply@github.com>2021-12-30 19:19:16 +0100
commitd2e72c40b251373fd662cab426fc04dcac1eb65a (patch)
tree6a85ad219a06c9814f00cd15d96d1171b997f623 /src/utils.js
parent4a0ce8d918007a3ed39bd15c28fc1c7931080271 (diff)
parent9d8ceea77b6f172f0c055c0061bc07e6f45c0d2d (diff)
downloadViper-d2e72c40b251373fd662cab426fc04dcac1eb65a.tar.gz
Viper-d2e72c40b251373fd662cab426fc04dcac1eb65a.zip
Merge branch 'main' into feat/version-indicator
Diffstat (limited to 'src/utils.js')
-rw-r--r--src/utils.js21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/utils.js b/src/utils.js
index 277c729..06acbdf 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -29,7 +29,7 @@ if (fs.existsSync("viper.json")) {
settings = {...settings, ...JSON.parse(fs.readFileSync("viper.json", "utf8"))};
settings.zip = path.join(settings.gamepath + "/northstar.zip");
} else {
- console.log(lang("gui.missinggamepath"));
+ console.log(lang("general.missinggamepath"));
}
function setpath(win) {
@@ -71,6 +71,7 @@ function update() {
}
}
+ ipcMain.emit("ns-updating");
console.log(lang("cli.update.checking"));
var version = getNSVersion();
@@ -82,12 +83,17 @@ function update() {
var tag = body["tag_name"];
if (version === tag) {
+ ipcMain.emit("ns-updated");
console.log(lang("cli.update.uptodate"), version);
+
+ winLog(lang("gui.update.uptodate"));
return;
} else {
if (version != "unknown") {
console.log(lang("cli.update.current"), version);
- }; console.log(lang("cli.update.downloading"), tag);
+ }; console.log(lang("cli.update.downloading") + ":", tag);
+
+ winLog(lang("gui.update.downloading"));
}
https.get(body.assets[0].browser_download_url, (res) => {
@@ -95,11 +101,10 @@ function update() {
res.pipe(stream);
stream.on("finish", () => {
stream.close();
+ winLog(lang("gui.update.extracting"));
console.log(lang("cli.update.downloaddone"));
fs.createReadStream(settings.zip).pipe(unzip.Extract({path: settings.gamepath}))
.on("finish", () => {
- console.log(lang("cli.update.finished"));
-
fs.writeFileSync(path.join(settings.gamepath, "ns_version.txt"), tag);
ipcMain.emit("getversion");
@@ -110,6 +115,9 @@ function update() {
}
}
+ ipcMain.emit("ns-updated");
+ winLog(lang("gui.update.finished"));
+ console.log(lang("cli.update.finished"));
cli.exit();
});
})
@@ -136,7 +144,12 @@ function launch(version) {
}
}
+function winLog(msg) {
+ ipcMain.emit("winLog", msg, msg);
+}
+
module.exports = {
+ winLog,
launch,
update,
setpath,