-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added 'check for updates' button * Added GitHub API integration for update checker * Removed dummy tag for testing * Changed update dialog text strings * Added logo to dialogs
- Loading branch information
1 parent
cc50a7f
commit d9cab3b
Showing
3 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
|
||
var remote = window.require('remote'); | ||
var pjson = remote.require('./package.json'); | ||
var rp = window.require('request-promise') | ||
var _ = require('lodash') | ||
|
||
var GitHub = function(options) { | ||
this._repo = 'http://github.com/gillesdemey/Cumulus' | ||
this._endpoint = 'https://api.github.com/repos/gillesdemey/cumulus' | ||
} | ||
|
||
GitHub.prototype.getRepoUrl = function() { | ||
return this._repo; | ||
} | ||
|
||
GitHub.prototype.checkForUpdates = function() { | ||
return this.getLatestRelease().then(function(response) { | ||
var tag = response.tag_name.replace(/v/g, '') | ||
|
||
if(pjson.version == tag) { | ||
return Promise.resolve('Cumulus is currently up-to-date.') | ||
} else { | ||
return Promise.reject('A new version of Cumulus is available.') | ||
} | ||
}, function(error) { | ||
return Promise.reject('Cumulus was not able to check version information.'); | ||
}) | ||
} | ||
|
||
GitHub.prototype.getLatestRelease = function() { | ||
var options = { | ||
uri: this._endpoint + '/releases/latest', | ||
json: true, | ||
headers: { | ||
'User-Agent': 'gillesdemey/Cumulus' | ||
}, | ||
} | ||
|
||
return rp(options); | ||
} | ||
|
||
module.exports = new GitHub(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.