Skip to content

Commit 6c9ccbc

Browse files
committed
Auto Update Electron ✨
1 parent 7bf8bc8 commit 6c9ccbc

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

src/main/autoUpdater.js

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
import { autoUpdater } from "electron-updater";
2-
import log from "electron-log";
3-
4-
export const electronUpdater = win => {
5-
autoUpdater.logger = log;
6-
autoUpdater.logger.transports.file.level = "info";
7-
log.info("App starting...");
8-
9-
function sendStatusToWindow(text) {
10-
log.info(text);
11-
win.webContents.send("message", text);
12-
}
13-
14-
autoUpdater.on("checking-for-update", () => {
15-
sendStatusToWindow("Checking for update...");
16-
});
17-
autoUpdater.on("update-available", info => {
18-
sendStatusToWindow("Update available.");
19-
});
20-
autoUpdater.on("update-not-available", info => {
21-
sendStatusToWindow("Update not available.");
22-
});
23-
autoUpdater.on("error", err => {
24-
sendStatusToWindow("Error in auto-updater. " + err);
25-
});
26-
autoUpdater.on("download-progress", progressObj => {
27-
let log_message = "Download speed: " + progressObj.bytesPerSecond;
28-
log_message = log_message + " - Downloaded " + progressObj.percent + "%";
29-
log_message =
30-
log_message +
31-
" (" +
32-
progressObj.transferred +
33-
"/" +
34-
progressObj.total +
35-
")";
36-
sendStatusToWindow(log_message);
37-
});
38-
autoUpdater.on("update-downloaded", info => {
39-
sendStatusToWindow("Update downloaded");
40-
});
41-
};
1+
// import { autoUpdater } from "electron-updater";
2+
// import log from "electron-log";
3+
4+
// export const electronUpdater = win => {
5+
// autoUpdater.logger = log;
6+
// autoUpdater.logger.transports.file.level = "info";
7+
// log.info("App starting...");
8+
9+
// function sendStatusToWindow(text) {
10+
// log.info(text);
11+
// win.webContents.send("autoupdater-message", text);
12+
// }
13+
14+
// autoUpdater.on("checking-for-update", () => {
15+
// sendStatusToWindow("Checking for update...");
16+
// });
17+
18+
// autoUpdater.on("update-available", info => {
19+
// sendStatusToWindow("Update available.");
20+
// });
21+
22+
// autoUpdater.on("update-not-available", info => {
23+
// sendStatusToWindow("Update not available.");
24+
// });
25+
26+
// autoUpdater.on("error", err => {
27+
// sendStatusToWindow("Error in auto-updater. " + err);
28+
// });
29+
30+
// autoUpdater.on("download-progress", progressObj => {
31+
// const log_message = `Download speed: ${
32+
// progressObj.bytesPerSecond
33+
// } - Downloaded ${progressObj.percent} % ${log_message} ( ${
34+
// progressObj.transferred
35+
// } / ${progressObj.total} )`;
36+
// sendStatusToWindow(log_message);
37+
// });
38+
39+
// autoUpdater.on("update-downloaded", info => {
40+
// sendStatusToWindow("Update downloaded");
41+
// });
42+
// };

src/main/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const isDevelopment = process.env.NODE_ENV !== "production";
77

88
import { createMenu } from "./menu";
99
import { createMainWindow } from "./createWindow";
10-
import { electronUpdater } from "./autoUpdater";
10+
// import { electronUpdater } from "./autoUpdater";
1111

1212
// global reference to mainWindow (necessary to prevent window from being garbage collected)
1313
let mainWindow;
@@ -31,7 +31,7 @@ app.on("activate", () => {
3131
app.on("ready", () => {
3232
mainWindow = createMainWindow(mainWindow);
3333
createMenu();
34-
electronUpdater(mainWindow);
34+
// electronUpdater(mainWindow);
3535
autoUpdater.checkForUpdatesAndNotify();
3636
});
3737

0 commit comments

Comments
 (0)