version match tested working
This commit is contained in:
parent
b6c6b81e73
commit
fdde0067eb
|
@ -24,11 +24,23 @@ module.exports = function (pkg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNewer(latest, myPkg) {
|
function isNewer(latest, myPkg) {
|
||||||
var m = /^(v)?(\d+)\.(\d+)\.(\d+)(.*)/.exec(latest.version);
|
//console.log('sort result:', sortLatest(latest, myPkg));
|
||||||
var n = /^(v)?(\d+)\.(\d+)\.(\d+)(.*)/.exec(myPkg.version);
|
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 (!m) {
|
||||||
|
if (!n) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (!n) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(m[2], 10) > parseInt(n[2], 10)) {
|
if (parseInt(m[2], 10) > parseInt(n[2], 10)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (parseInt(m[2], 10) === parseInt(n[2], 10)) {
|
} 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)) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
console.log('Upgrade Available: ' + next.version + ' in \'' + next.channel + '\'channel');
|
console.log('Upgrade Available: ' + next.version + ' in \'' + next.channel + '\'channel');
|
||||||
|
|
Loading…
Reference in New Issue