fix(version): compare semver numbers

Values were being compared as whole strings.
This commit is contained in:
Linden
2022-08-22 20:53:55 +10:00
parent 8defbaf78f
commit f5c5597277
2 changed files with 19 additions and 8 deletions

View File

@@ -17,11 +17,16 @@ function lib.versionCheck(repository)
if response.prerelease then return end
local latestVersion = response.tag_name:match('%d%.%d+%.%d+')
if not latestVersion then return end
if not latestVersion or latestVersion == currentVersion then return end
if currentVersion >= latestVersion then return end
local cv = { string.strsplit('.', currentVersion) }
local lv = { string.strsplit('.', latestVersion) }
print(('^3An update is available for %s (current version: %s)\r\n%s^0'):format(resource, currentVersion, response.html_url))
for i = 1, #cv do
if tonumber(cv[i]) < tonumber(lv[i]) then
return print(('^3An update is available for %s (current version: %s)\r\n%s^0'):format(resource, currentVersion, response.html_url))
end
end
end, 'GET')
end)
end