Beta's were considered older than all normals
This commit is contained in:
@@ -36,16 +36,28 @@ function is_newer_version(current, latest) {
|
|||||||
const currentParts = current.match(pattern);
|
const currentParts = current.match(pattern);
|
||||||
const latestParts = latest.match(pattern);
|
const latestParts = latest.match(pattern);
|
||||||
|
|
||||||
|
if (!currentParts || !latestParts) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Normal version comparisons
|
// Normal version comparisons
|
||||||
const major = latestParts[1] > currentParts[1];
|
const major = latestParts[1] - currentParts[1];
|
||||||
const minor = latestParts[2] > currentParts[2];
|
const minor = latestParts[2] - currentParts[2];
|
||||||
const patch = latestParts[3] > currentParts[3];
|
const patch = latestParts[3] - currentParts[3];
|
||||||
|
|
||||||
// If current is a pre-release, and latest is a release
|
// If current is a pre-release, and latest is a release
|
||||||
const prerelease = latestParts[4].length === 0 && currentParts[4].length > 0;
|
const betaToRelease = latestParts[4].length === 0 && currentParts[4].length > 0;
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case major > 0:
|
||||||
|
case major === 0 && minor > 0:
|
||||||
|
case major === 0 && minor === 0 && patch > 0:
|
||||||
|
case major === 0 && minor === 0 && patch === 0 && betaToRelease:
|
||||||
|
return true;
|
||||||
|
|
||||||
// 'latest' is newer than 'current' if any of them are true
|
default:
|
||||||
return major || minor || patch || prerelease;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_object(o) {return o !== null && typeof o == 'object'}
|
function is_object(o) {return o !== null && typeof o == 'object'}
|
||||||
|
|||||||
Reference in New Issue
Block a user