Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit 9972b71

Browse files
author
Axel Rindle
committed
Remove some dependencies and add semver package for comparing
1 parent 8041a94 commit 9972b71

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

lib/main.coffee

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# require npm modules
22
got = require 'got'
3-
semcmp = require 'semver-compare'
43
chalk = 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

98
module.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

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
"chalk": "^1.1.3",
1818
"coffeescript": "^1.12.7",
1919
"got": "^7.1.0",
20-
"promise": "^7.3.1",
21-
"semver-compare": "^1.0.0",
22-
"sprintf-js": "^1.1.1"
20+
"semver": "^5.4.1"
2321
},
2422
"devDependencies": {
2523
"gulp": "github:gulpjs/gulp#4.0",

0 commit comments

Comments
 (0)