version match tested working

This commit is contained in:
AJ ONeal 2018-06-14 05:35:39 -06:00
parent b6c6b81e73
commit fdde0067eb
1 changed files with 15 additions and 3 deletions

View File

@ -24,11 +24,23 @@ module.exports = function (pkg) {
}
function isNewer(latest, myPkg) {
var m = /^(v)?(\d+)\.(\d+)\.(\d+)(.*)/.exec(latest.version);
var n = /^(v)?(\d+)\.(\d+)\.(\d+)(.*)/.exec(myPkg.version);
if (!m) {
return 1;
//console.log('sort result:', sortLatest(latest, myPkg));
return sortLatest(latest, myPkg) < 0;
}
function sortLatest(latest, myPkg) {
var m = /^(v)?(\d+)\.(\d+)\.(\d+)(.*)/.exec(latest);
var n = /^(v)?(\d+)\.(\d+)\.(\d+)(.*)/.exec(myPkg);
//console.log('m', m);
//console.log('n', n);
if (!m) {
if (!n) {
return 0;
}
return 1;
} else if (!n) {
return -1;
}
if (parseInt(m[2], 10) > parseInt(n[2], 10)) {
return -1;
} else if (parseInt(m[2], 10) === parseInt(n[2], 10)) {
@ -88,7 +100,7 @@ module.exports = function (pkg) {
}
});
if (!next || !isNewer(next.version, pkg.version)) {
console.log('DEBUG can\'t upgrade from', pkg.version, 'in channel', chan);
//console.log('DEBUG can\'t upgrade from', pkg.version, 'in channel', chan);
return;
}
console.log('Upgrade Available: ' + next.version + ' in \'' + next.channel + '\'channel');