Skip to content

Commit

Permalink
Fix getVersion returning an undefined version
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Jul 30, 2016
1 parent 0d43c4d commit dd6b4ef
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,13 @@ module.exports = {
getVersion: function(args){
return (isLegacyVersion(args.desiredVersion) ? getLegacyVersions : getVersionsFromManifest)(args.downloadUrl)
.then(function(versions) {
var version = versions.find(function(version){
if(version.version === args.desiredVersion) {
return version;
}
var version = versions.findIndex(function(version){
return version.version === args.desiredVersion;
});

if(version){
return version;
}
throw new Error('Version ' + args.desiredVersion + ' not found.');
return version >= 0
? Promise.resolve(versions[version])
: Promise.reject('Version ' + args.desiredVersion + ' not found.');
});
},
/**
Expand Down

0 comments on commit dd6b4ef

Please sign in to comment.