diff options
Diffstat (limited to 'src/utils.js')
-rw-r--r-- | src/utils.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/utils.js b/src/utils.js index 7e9dbac..b4ff04d 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")); const version = getInstalledVersion(); @@ -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,15 +101,12 @@ 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); - events.emit("updated"); - for (let i = 0; i < settings.excludes.length; i++) { let exclude = path.join(settings.gamepath + "/" + settings.excludes[i]); if (fs.existsSync(exclude + ".excluded")) { @@ -111,6 +114,9 @@ function update() { } } + ipcMain.emit("ns-updated"); + winLog(lang("gui.update.finished")); + console.log(lang("cli.update.finished")); cli.exit(); }); }) @@ -137,7 +143,12 @@ function launch(version) { } } +function winLog(msg) { + ipcMain.emit("winLog", msg, msg); +} + module.exports = { + winLog, launch, update, setpath, |