Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit f9e8e6c

Browse files
committed
Added: electron-autoupdater
1 parent e7b794d commit f9e8e6c

4 files changed

Lines changed: 90 additions & 31 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,5 @@ dist
106106
# custom
107107
temp.js
108108
Mr.Dclutterer-flat.md
109-
dist/
109+
dist/
110+
electron-builder.yml

main.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ const path = require('path');
44
const FileTypes = require('./file-types.json');
55
const fs = require('fs');
66
const contextMenu = require('electron-context-menu');
7-
87
const appVersion = app.getVersion();
8+
const { autoUpdater } = require('electron-updater');
9+
910

1011
var mode = 1; // by default works on file
1112
var handleDirs = true; // by default process directories with depth 1
@@ -151,8 +152,24 @@ function createWindow() {
151152
// win.webContents.openDevTools()
152153
}
153154

155+
win.once('ready-to-show', () => {
156+
autoUpdater.checkForUpdatesAndNotify();
157+
});
158+
159+
autoUpdater.on('update-available', () => {
160+
let currWin = BrowserWindow.getFocusedWindow();
161+
currWin.webContents.send('mode', "App Update Available");
162+
163+
});
164+
165+
autoUpdater.on('update-downloaded', () => {
166+
let currWin = BrowserWindow.getFocusedWindow();
167+
currWin.webContents.send('mode', "Restarting App To Update It");
168+
autoUpdater.quitAndInstall();
169+
});
170+
154171

155-
app.whenReady().then(createWindow)
172+
app.whenReady().then(createWindow);
156173

157174

158175
app.on('window-all-closed', () => {

package-lock.json

Lines changed: 60 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
"postinstall": "electron-builder install-app-deps",
1313
"start": "electron .",
1414
"pack": "build --dir",
15-
"dist:linux": "build -l --config",
16-
"dist:win": "electron-builder --windows nsis:ia32",
17-
"dist:deb": "electron-builder --linux deb tar.xz",
15+
"dist:linux": "build -l --config --publish never",
16+
"dist:win": "electron-builder --windows nsis:ia32 --publish never",
17+
"dist:deb": "electron-builder --linux deb tar.xz --publish never",
1818
"dist": "electron-builder",
19-
"dist:appimage": "electron-builder --linux AppImage"
19+
"dist:appimage": "electron-builder --linux AppImage --publish never",
20+
"deploy":"electron-builder build --linux --win --publish always"
2021
},
2122
"keywords": [
2223
"rename",
@@ -29,8 +30,8 @@
2930
],
3031
"license": "MIT",
3132
"repository": {
32-
"type" : "git",
33-
"url" : "https://github.com/deep5050/Mr.Dclutterer.git"
33+
"type": "git",
34+
"url": "https://github.com/deep5050/Mr.Dclutterer.git"
3435
},
3536
"homepage": "https://deep5050.github.io/Mr.Dclutterer",
3637
"devDependencies": {
@@ -39,6 +40,7 @@
3940
"electron-reload": "^1.5.0"
4041
},
4142
"dependencies": {
42-
"electron-context-menu": "^2.3.0"
43+
"electron-context-menu": "^2.3.0",
44+
"electron-updater": "^4.3.4"
4345
}
4446
}

0 commit comments

Comments
 (0)