Skip to content

Commit c685603

Browse files
committed
add example electron app
1 parent 5418656 commit c685603

File tree

5 files changed

+2797
-0
lines changed

5 files changed

+2797
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules
22
.nyc_output
3+
example/dist
4+
example/node_modules

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,14 @@ WIP public electron update server.
1212
```bash
1313
$ npm install
1414
$ npm start
15+
```
16+
17+
To try with an actual electron app, run:
18+
19+
```bash
20+
$ npm start &
21+
$ cd example
22+
$ npm install
23+
$ npm run build
24+
$ ./dist/mac/dat-desktop.app/Contents/MacOS/dat-desktop
1525
```

example/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict'
2+
3+
const { autoUpdater } = require('electron')
4+
5+
const server = 'http://localhost:3000'
6+
const feed = `${server}/dat-land/dat-desktop/${process.platform}/0.0.0`
7+
8+
autoUpdater.setFeedURL(feed)
9+
autoUpdater.checkForUpdates()
10+
11+
autoUpdater.on('checking-for-update', () => {
12+
console.log('checking-for-update')
13+
})
14+
15+
autoUpdater.on('update-available', () => {
16+
console.log('update-available')
17+
})
18+
19+
autoUpdater.on('update-not-available', () => {
20+
console.log('update-not-available')
21+
})
22+
23+
autoUpdater.on(
24+
'update-downloaded',
25+
(event, releaseNotes, releaseName, updateURL) => {
26+
console.log('update-downloaded', {
27+
event,
28+
releaseNotes,
29+
releaseName,
30+
updateURL
31+
})
32+
}
33+
)
34+
35+
autoUpdater.on('error', error => {
36+
console.log('error', { error })
37+
})

0 commit comments

Comments
 (0)