Skip to content

Commit

Permalink
refactor auto update function
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoxor committed Jun 16, 2022
1 parent b5cd9c1 commit c26adda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "amethyst",
"author": "amethyst <geoxor123@outlook.com>",
"productName": "Amethyst",
"version": "1.3.6",
"version": "1.3.7",
"main": "./release/dist/main/main.js",
"licenses": [
{
Expand Down
13 changes: 9 additions & 4 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ else {
}).catch(console.error);
}

if (!IS_DEV) {
app
.whenReady()
.then(() => import("electron-updater"))
async function checkForUpdatesAndInstall() {
return import("electron-updater")
.then(({ autoUpdater }) => {
autoUpdater.checkForUpdatesAndNotify({
title: "Update Available",
Expand All @@ -79,4 +77,11 @@ if (!IS_DEV) {
autoUpdater.on("update-downloaded", () => autoUpdater.quitAndInstall(true, true));
})
.catch(e => console.error("Failed check updates:", e));
}

if (!IS_DEV) {
app
.whenReady()
.then(checkForUpdatesAndInstall)
.then(() => console.log("Updates installed"));
}

0 comments on commit c26adda

Please sign in to comment.