File tree Expand file tree Collapse file tree 5 files changed +96
-0
lines changed
Expand file tree Collapse file tree 5 files changed +96
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ # electronautoupdate
2+ The most basic autoupdate setup for electron I managed to create
Original file line number Diff line number Diff line change 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+ } )
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments