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

Commit 5e665e2

Browse files
author
Axel Rindle
committed
Trim option values and return as soon as an option value is invalid
1 parent f56a6be commit 5e665e2

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

lib/main.coffee

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,25 @@ module.exports = (options, callback) ->
3333
###
3434
check = (options, callback) ->
3535
# get options
36-
token = options.token
37-
repo = options.repo
38-
owner = options.owner
39-
currentVersion = options.currentVersion
36+
token = options.token.trim()
37+
repo = options.repo.trim()
38+
owner = options.owner.trim()
39+
currentVersion = options.currentVersion.trim()
4040
fetchTags = options.fetchTags || false
4141

4242
# check if required options are defined
43-
callback('no token specified', null) if token is undefined
44-
callback('no repository specified', null) if repo is undefined
45-
callback('no owner specified', null) if owner is undefined
46-
callback('no current version given', null) if currentVersion is undefined
43+
if token is undefined or token is ''
44+
callback('no token specified', null)
45+
return
46+
if repo is undefined or repo is ''
47+
callback('no repository specified', null)
48+
return
49+
if owner is undefined or owner is ''
50+
callback('no owner specified', null)
51+
return
52+
if currentVersion is undefined or currentVersion is ''
53+
callback('no current version given', null)
54+
return
4755

4856
# build the query
4957
query = if fetchTags then query.tags repo, owner else query.releases repo, owner

0 commit comments

Comments
 (0)