From fdde0067eb4b6d8e56e8421bdb5133fc0362197e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 14 Jun 2018 05:35:39 -0600 Subject: [PATCH] version match tested working --- lib/updater.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/updater.js b/lib/updater.js index a5d9fb5..f509586 100644 --- a/lib/updater.js +++ b/lib/updater.js @@ -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); + //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');