Comparison

core/modulemanager.lua @ 12275:13624194984b

core.modulemanager: Save module metadata for potential later use Makes it reachable from the shell if nothing else
author Kim Alvefur <zash@zash.se>
date Sat, 05 Feb 2022 01:33:46 +0100
parent 12257:7adfd5d29576
child 12450:7efd4bcaa95c
comparison
equal deleted inserted replaced
12274:10447f940fec 12275:13624194984b
217 , { __index = api }); 217 , { __index = api });
218 218
219 local pluginenv = setmetatable({ module = api_instance }, { __index = _G }); 219 local pluginenv = setmetatable({ module = api_instance }, { __index = _G });
220 api_instance.environment = pluginenv; 220 api_instance.environment = pluginenv;
221 221
222 local mod, err = loader:load_code(module_name, nil, pluginenv); 222 local mod, err, meta = loader:load_code(module_name, nil, pluginenv);
223 if not mod then 223 if not mod then
224 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); 224 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
225 api_instance:set_status("error", "Failed to load (see log)"); 225 api_instance:set_status("error", "Failed to load (see log)");
226 return nil, err; 226 return nil, err;
227 end 227 end
228 228
229 api_instance.path = err; 229 api_instance.path = err;
230 api_instance.meta = meta;
230 231
231 local custom_plugins = prosody.paths.installer; 232 local custom_plugins = prosody.paths.installer;
232 if custom_plugins and err:sub(1, #custom_plugins+1) == custom_plugins.."/" then 233 if custom_plugins and err:sub(1, #custom_plugins+1) == custom_plugins.."/" then
233 -- Stage 1: Make it work (you are here) 234 -- Stage 1: Make it work (you are here)
234 -- Stage 2: Make it less hacky (TODO) 235 -- Stage 2: Make it less hacky (TODO)