-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic Check update for platforms without auto updates
- Loading branch information
1 parent
88880e6
commit 49962da
Showing
3 changed files
with
80 additions
and
19 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
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,30 @@ | ||
const request = require('request') | ||
|
||
/* | ||
* Checks for update given the url. | ||
* Returns the Update object with '' | ||
*/ | ||
module.exports = function CheckUpdate(url, next) { | ||
request({ | ||
url: url, | ||
json: true, | ||
}, function (error, response, body) { | ||
if (error) { | ||
return next && next('Failed to check for updates') | ||
} | ||
|
||
if (response.statusCode == 200) { | ||
// New update available. Parse version | ||
body.version = body.url.match(/version\/([\d\.]*)/g)[1] || body.name | ||
module.exports.newUpdate = body | ||
return next && next(null, body) | ||
} | ||
|
||
return next && next(null, null) | ||
}) | ||
} | ||
|
||
/* | ||
* Stores if there is an update | ||
*/ | ||
module.exports.newUpdate = false |