Skip to content

Commit

Permalink
Fix getVersion returning an undefined version (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer authored and adam-lynch committed Jul 30, 2016
1 parent 13767ed commit ff97d78
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 ff97d78

Please sign in to comment.