11# require npm modules
22got = require ' got'
3- semcmp = require ' semver-compare'
43chalk = require ' chalk'
5- sprintf = require ( ' sprintf-js ' ). sprintf
4+ semver = require ' semver '
65
7- baseApiUrl = ' https://api.github.com/repos/%s /releases'
6+ baseApiUrl = ' https://api.github.com/repos/REPO /releases'
87
98module .exports = (options , callback ) ->
109 if callback
@@ -26,7 +25,7 @@ check = (options, callback) ->
2625 callback (null , ' no current version given' ) if currentVersion is undefined
2726
2827 # do the api call
29- apiUrl = sprintf baseApiUrl, repo
28+ apiUrl = baseApiUrl . replace ' REPO ' , repo
3029 if not includePreReleases then apiUrl += ' /latest'
3130 got (apiUrl).then ((response ) ->
3231 # parse the response body into an object
@@ -39,20 +38,18 @@ check = (options, callback) ->
3938 # if a remote version is higher than the installed one, the callback
4039 # will be called with the release object
4140 for release in releases
42- tag = release .tag_name . replace ( / [ ^ 0-9 $ . ,] / g , ' ' )
43- if semcmp (currentVersion, tag) is - 1
41+ tag = release .tag_name
42+ if semver . compare (currentVersion, tag) is - 1
4443 found = true
4544 callback release, null
4645 break
4746 else
48- tag = releases .tag_name . replace ( / [ ^ 0-9 $ . ,] / g , ' ' )
49- if semcmp (currentVersion, tag) is - 1
47+ tag = releases .tag_name
48+ if semver . compare (currentVersion, tag) is - 1
5049 found = true
5150 callback releases, null
5251
5352 callback (null , null ) if not found
54- ).catch ((error ) ->
55- callback null , error
56- )
53+ ).catch (error) -> callback null , error
5754
5855 return null
0 commit comments