fix(node): use semver sort

This commit is contained in:
Rhys Arkins 2018-05-29 15:17:41 +02:00
parent 1da997dbe6
commit 5475e567d7

View file

@ -3,8 +3,9 @@ const {
getMinor, getMinor,
isGreaterThan, isGreaterThan,
isPinnedVersion, isPinnedVersion,
sortVersions,
} = require('../../../versioning/semver'); } = require('../../../versioning/semver');
const { getRepoTags, sortVersions } = require('../../../datasource/github'); const { getRepoTags } = require('../../../datasource/github');
async function getPackageUpdates(config) { async function getPackageUpdates(config) {
logger.debug('getPackageUpdates()'); logger.debug('getPackageUpdates()');
@ -28,8 +29,8 @@ async function getPackageUpdates(config) {
const newReleases = (await getRepoTags('nodejs/node')) const newReleases = (await getRepoTags('nodejs/node'))
.map(release => release.replace(/^v/, '')) .map(release => release.replace(/^v/, ''))
.filter(release => getMajor(currentVersion) === getMajor(release)) .filter(release => getMajor(currentVersion) === getMajor(release))
.filter(release => isGreaterThan(release, currentVersion)) .filter(release => isGreaterThan(release, currentVersion));
.sort(sortVersions); newReleases.sort(sortVersions);
// istanbul ignore if // istanbul ignore if
if (endpoint) { if (endpoint) {
logger.debug('Restoring GHE token and endpoint'); logger.debug('Restoring GHE token and endpoint');
@ -41,7 +42,7 @@ async function getPackageUpdates(config) {
} else { } else {
return []; return [];
} }
const newVersion = newReleases.pop(); const newVersion = newReleases[newReleases.length - 1];
return [ return [
{ {
type: getMajor(newVersion) > getMajor(currentVersion) ? 'major' : 'minor', type: getMajor(newVersion) > getMajor(currentVersion) ? 'major' : 'minor',