Software / code / prosody
Comparison
core/modulemanager.lua @ 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 |
| parent | 13614:601ec2c19180 |
| child | 13689:6049c1602c79 |
comparison
equal
deleted
inserted
replaced
| 13614:601ec2c19180 | 13615:b03b5716e4cf |
|---|---|
| 64 value = value:gsub("%s+$", ""); | 64 value = value:gsub("%s+$", ""); |
| 65 metadata[key] = value; | 65 metadata[key] = value; |
| 66 end | 66 end |
| 67 end | 67 end |
| 68 | 68 |
| 69 if metadata.lua then | |
| 70 local supported = false; | |
| 71 for supported_lua_version in metadata.lua:gmatch("[^, ]+") do | |
| 72 if supported_lua_version == lua_version then | |
| 73 supported = true; | |
| 74 break; | |
| 75 end | |
| 76 end | |
| 77 if not supported then | |
| 78 log("warn", "Not loading module, we have Lua %s but the module requires one of (%s): %s", lua_version, metadata.lua, path); | |
| 79 return; -- Don't load this module | |
| 80 end | |
| 81 end | |
| 82 | |
| 69 if metadata.conflicts then | 83 if metadata.conflicts then |
| 70 local conflicts_features = set.new(array.collect(metadata.conflicts:gmatch("[^, ]+"))); | 84 local conflicts_features = set.new(array.collect(metadata.conflicts:gmatch("[^, ]+"))); |
| 71 local conflicted_features = set.intersection(conflicts_features, core_features); | 85 local conflicted_features = set.intersection(conflicts_features, core_features); |
| 72 if not conflicted_features:empty() then | 86 if not conflicted_features:empty() then |
| 73 log("warn", "Not loading module, due to conflicting features '%s': %s", conflicted_features, path); | 87 log("warn", "Not loading module, due to conflicting features '%s': %s", conflicted_features, path); |