Changeset

13615:b03b5716e4cf

modulemanager: Allow modules to specify supported Lua versions in metadata
author Matthew Wild <mwild1@gmail.com>
date Thu, 09 Jan 2025 16:44:48 +0000
parents 13614:601ec2c19180
children 13616:2f38f3275a74
files core/modulemanager.lua
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/core/modulemanager.lua	Thu Jan 09 16:06:53 2025 +0000
+++ b/core/modulemanager.lua	Thu Jan 09 16:44:48 2025 +0000
@@ -66,6 +66,20 @@
 			end
 		end
 
+		if metadata.lua then
+			local supported = false;
+			for supported_lua_version in metadata.lua:gmatch("[^, ]+") do
+				if supported_lua_version == lua_version then
+					supported = true;
+					break;
+				end
+			end
+			if not supported then
+				log("warn", "Not loading module, we have Lua %s but the module requires one of (%s): %s", lua_version, metadata.lua, path);
+				return; -- Don't load this module
+			end
+		end
+
 		if metadata.conflicts then
 			local conflicts_features = set.new(array.collect(metadata.conflicts:gmatch("[^, ]+")));
 			local conflicted_features = set.intersection(conflicts_features, core_features);