Skip to content

Commit

Permalink
fix: getModuleByRange don't list all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-horse committed Jul 11, 2016
1 parent 79ac9fb commit 2c606ef
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions services/package.js
Expand Up @@ -75,7 +75,7 @@ exports.getModuleByTag = function* (name, tag) {
};

exports.getModuleByRange = function* (name, range) {
var rows = yield exports.listModulesByName(name);
var rows = yield exports.listModulesByName(name, [ 'id', 'version' ]);
var versionMap = {};
var versions = rows.map(function(row) {
versionMap[row.version] = row;
Expand All @@ -85,7 +85,12 @@ exports.getModuleByRange = function* (name, range) {
});

var version = semver.maxSatisfying(versions, range);
return versionMap[version];
if (!versionMap[version]) {
return null;
}

var id = versionMap[version].id;
return yield exports.getModuleById(id);
};

exports.getLatestModule = function* (name) {
Expand Down Expand Up @@ -241,12 +246,13 @@ exports.listAllPublicModuleNames = function* () {
});
};

exports.listModulesByName = function* (moduleName) {
exports.listModulesByName = function* (moduleName, attributes) {
var mods = yield Module.findAll({
where: {
name: moduleName
},
order: [ ['id', 'DESC'] ]
order: [ ['id', 'DESC'] ],
attributes,
});

for (var mod of mods) {
Expand Down

0 comments on commit 2c606ef

Please sign in to comment.