Skip to content

Commit e43882f

Browse files
committed
eapp
0 parents  commit e43882f

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
lines changed

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
/dist
12+
13+
# misc
14+
.DS_Store
15+
.env.local
16+
.env.development.local
17+
.env.test.local
18+
.env.production.local
19+
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*
23+
24+
# yarn
25+
package-lock.json
26+
yarn.lock
27+
28+
electron-builder.yml

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# electronautoupdate
2+
The most basic autoupdate setup for electron I managed to create

electron.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const {app, BrowserWindow, ipcMain} = require('electron');
2+
const {autoUpdater} = require("electron-updater");
3+
let win; // this wills store the window object
4+
5+
function createDefaultWindow() {
6+
win = new BrowserWindow({width: 900, height: 680});
7+
win.loadURL(`file://${__dirname}/index.html`);
8+
win.on('closed', () => app.quit());
9+
return win;
10+
}
11+
12+
// when the update is ready, notify the BrowserWindow
13+
autoUpdater.on('update-downloaded', (info) => {
14+
win.webContents.send('updateReady')
15+
});
16+
app.on('ready', function() {
17+
createDefaultWindow();
18+
autoUpdater.checkForUpdates();
19+
});
20+
ipcMain.on("quitAndInstall", (event, arg) => {
21+
autoUpdater.quitAndInstall();
22+
})

index.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<html>
2+
3+
<head>
4+
<title>Electron AutoUpdater</title>
5+
</head>
6+
7+
<body>
8+
<script>
9+
const ipcRenderer = require('electron').ipcRenderer;
10+
11+
// wait for an updateReady message
12+
ipcRenderer.on('updateReady', function(event, text) {
13+
// changes the text of the button
14+
var container = document.getElementById('ready');
15+
container.innerHTML = "new version ready!";
16+
})
17+
</script>
18+
Version: <span id="version">v0.1.10</span>
19+
<!-- the button onClick sends a quitAndInstall message to the electron main process -->
20+
<button id="ready" onClick="ipcRenderer.send('quitAndInstall')">no updates ready</button>
21+
22+
</body>
23+
24+
</html>

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "electronautoupdate",
3+
"version": "0.1.10",
4+
"author": "Pingwin",
5+
"homepage": "./",
6+
"description": "An example of an autoupdating electron app",
7+
"repository": "https://github.com/SzAkos/elcr",
8+
"main": "electron.js",
9+
"dependencies": {
10+
"electron-updater": "^2.10.1"
11+
},
12+
"scripts": {
13+
"build": "build --win",
14+
"ship": "build --win -p always"
15+
},
16+
"devDependencies": {
17+
"electron": "^1.7.5",
18+
"electron-builder": "^19.20.1"
19+
}
20+
}

0 commit comments

Comments
 (0)