X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=util%2Fpluginloader.lua;h=0d7eafa7a154122d3af7242bac792349963794b6;hb=a8958cbe5ebad3abc12efa7a76c8aedac8f21389;hp=b894f5279dae89d5497482edc77528ec6e285451;hpb=9cd5c05ecd73c691966be58796545081b168f958;p=prosody.git diff --git a/util/pluginloader.lua b/util/pluginloader.lua index b894f527..0d7eafa7 100644 --- a/util/pluginloader.lua +++ b/util/pluginloader.lua @@ -17,9 +17,7 @@ end local io_open = io.open; local envload = require "util.envload".envload; -module "pluginloader" - -function load_file(names) +local function load_file(names) local file, err, path; for i=1,#plugin_dir do for j=1,#names do @@ -35,20 +33,20 @@ function load_file(names) return file, err; end -function load_resource(plugin, resource) +local function load_resource(plugin, resource) resource = resource or "mod_"..plugin..".lua"; local names = { - "mod_"..plugin.."/"..plugin.."/"..resource; -- mod_hello/hello/mod_hello.lua - "mod_"..plugin.."/"..resource; -- mod_hello/mod_hello.lua - plugin.."/"..resource; -- hello/mod_hello.lua - resource; -- mod_hello.lua + "mod_"..plugin..dir_sep..plugin..dir_sep..resource; -- mod_hello/hello/mod_hello.lua + "mod_"..plugin..dir_sep..resource; -- mod_hello/mod_hello.lua + plugin..dir_sep..resource; -- hello/mod_hello.lua + resource; -- mod_hello.lua }; return load_file(names); end -function load_code(plugin, resource, env) +local function load_code(plugin, resource, env) local content, err = load_resource(plugin, resource); if not content then return content, err; end local path = err; @@ -57,4 +55,8 @@ function load_code(plugin, resource, env) return f, path; end -return _M; +return { + load_file = load_file; + load_resource = load_resource; + load_code = load_code; +};