|
1 | 1 | var app = require('app');
|
2 | 2 | var path = require('path');
|
3 | 3 | var ipc = require('ipc');
|
4 |
| -var autoUpdater = require('auto-updater'); |
| 4 | +var ghReleases = require('electron-gh-releases'); |
5 | 5 |
|
6 | 6 | require('crash-reporter').start();
|
7 | 7 |
|
@@ -94,32 +94,34 @@ app.on('ready', function(){
|
94 | 94 |
|
95 | 95 | function checkAutoUpdate() {
|
96 | 96 |
|
97 |
| - autoUpdater |
98 |
| - .on('error', function(event, message) { |
99 |
| - console.log('ERRORED.'); |
100 |
| - console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); |
101 |
| - app.dock.hide(); |
102 |
| - }) |
103 |
| - .on('checking-for-update', function () { |
104 |
| - console.log('Checking for update'); |
105 |
| - }) |
106 |
| - .on('update-available', function () { |
107 |
| - console.log('Update available'); |
108 |
| - // AutoUpdater Downloads the update automatically |
109 |
| - }) |
110 |
| - .on('update-not-available', function () { |
111 |
| - console.log('Update not available'); |
| 97 | + var autoUpdateOptions = { |
| 98 | + repo: 'ekonstantinidis/gitify', |
| 99 | + currentVersion: app.getVersion() |
| 100 | + }; |
| 101 | + |
| 102 | + var update = new ghReleases(autoUpdateOptions, function (autoUpdater) { |
| 103 | + autoUpdater |
| 104 | + .on('error', function(event, message) { |
| 105 | + console.log('ERRORED.'); |
| 106 | + console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message); |
| 107 | + }) |
| 108 | + .on('update-downloaded', function (event, releaseNotes, releaseName, |
| 109 | + releaseDate, updateUrl, quitAndUpdate) { |
| 110 | + console.log('Update downloaded'); |
| 111 | + confirmAutoUpdate(quitAndUpdate); |
| 112 | + }); |
| 113 | + }); |
| 114 | + |
| 115 | + // Check for updates |
| 116 | + update.check(function (err, status) { |
| 117 | + if (err || !status) { |
112 | 118 | app.dock.hide();
|
113 |
| - }) |
114 |
| - .on('update-downloaded', function (event, releaseNotes, releaseName, |
115 |
| - releaseDate, updateUrl, quitAndUpdate) { |
116 |
| - console.log('Update downloaded'); |
117 |
| - confirmAutoUpdate(quitAndUpdate); |
118 |
| - }); |
119 |
| - |
120 |
| - autoUpdater.setFeedUrl('https://raw.githubusercontent.com/' + |
121 |
| - 'ekonstantinidis/gitify/master/auto-update.json'); |
122 |
| - autoUpdater.checkForUpdates(); |
| 119 | + } |
| 120 | + |
| 121 | + if (!err && status) { |
| 122 | + update.download(); |
| 123 | + } |
| 124 | + }); |
123 | 125 | }
|
124 | 126 |
|
125 | 127 | function confirmAutoUpdate(quitAndUpdate) {
|
|
0 commit comments