diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/index.js b/src/index.js index 2a5ed2b..511aadb 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ const fs = require("fs"); const path = require("path"); +const { autoUpdater } = require("electron-updater"); const { app, dialog, ipcMain, BrowserWindow, ipcRenderer } = require("electron"); const Emitter = require("events"); @@ -46,6 +47,16 @@ function start() { win.webContents.once("dom-ready", () => { win.webContents.send("mods", utils.mods.list()); }); + + if (utils.settings.autoupdate) {utils.updatevp(false)} + + autoUpdater.on("update-downloaded", () => { + win.webContents.send("updateavailable") + }); + + ipcMain.on("updatenow", () => { + autoUpdater.quitAndInstall(); + }) } ipcMain.on("launch", (event) => {utils.launch()}) @@ -87,7 +98,11 @@ ipcMain.on("getmods", (event) => { process.chdir(app.getPath("appData")); if (cli.hasArgs()) { - cli.init(); + if (cli.hasParam("updatevp")) { + utils.updatevp(true); + } else { + cli.init(); + } } else { app.on("ready", () => { app.setPath("userData", path.join(app.getPath("cache"), app.name)); |