Skip to content

Commit

Permalink
refactor(resource/version): checkDependency optional print and return
Browse files Browse the repository at this point in the history
Send 'true' to match old behaviour (print message, return nil).
New behaviour has no output unless sending a third argument.
  • Loading branch information
thelindat committed Apr 18, 2022
1 parent f4e0739 commit 84ad4ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions resource/version/shared.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
function lib.checkDependency(resource, minimumVersion)
function lib.checkDependency(resource, minimumVersion, printMessage)
local currentVersion = GetResourceMetadata(resource, 'version', 0):match('%d%.%d+%.%d+')

if currentVersion < minimumVersion then
return print(("^1%s requires version '%s' of '%s' (current version: %s)^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion))
local msg = ("^1%s requires version '%s' of '%s' (current version: %s)^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion)

if printMessage then
return print(msg)
end

return false, msg
end

return true
Expand Down

0 comments on commit 84ad4ab

Please sign in to comment.