Software /
code /
prosody
Comparison
util/pluginloader.lua @ 11129:387d442497e7
util.pluginloader: Extract Lua version once
It's not going to change while the module is loaded.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 05 Oct 2020 20:56:03 +0200 |
parent | 10205:ff8de86b75f0 |
child | 11130:10485a3ef78b |
comparison
equal
deleted
inserted
replaced
11127:1d9cd1abc660 | 11129:387d442497e7 |
---|---|
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 -- luacheck: ignore 113/CFG_PLUGINDIR | 8 -- luacheck: ignore 113/CFG_PLUGINDIR |
9 | 9 |
10 local dir_sep, path_sep = package.config:match("^(%S+)%s(%S+)"); | 10 local dir_sep, path_sep = package.config:match("^(%S+)%s(%S+)"); |
11 local lua_version = _VERSION:match(" (.+)$"); | |
11 local plugin_dir = {}; | 12 local plugin_dir = {}; |
12 for path in (CFG_PLUGINDIR or "./plugins/"):gsub("[/\\]", dir_sep):gmatch("[^"..path_sep.."]+") do | 13 for path in (CFG_PLUGINDIR or "./plugins/"):gsub("[/\\]", dir_sep):gmatch("[^"..path_sep.."]+") do |
13 path = path..dir_sep; -- add path separator to path end | 14 path = path..dir_sep; -- add path separator to path end |
14 path = path:gsub(dir_sep..dir_sep.."+", dir_sep); -- coalesce multiple separaters | 15 path = path:gsub(dir_sep..dir_sep.."+", dir_sep); -- coalesce multiple separaters |
15 plugin_dir[#plugin_dir + 1] = path; | 16 plugin_dir[#plugin_dir + 1] = path; |
34 return file, err; | 35 return file, err; |
35 end | 36 end |
36 | 37 |
37 local function load_resource(plugin, resource) | 38 local function load_resource(plugin, resource) |
38 resource = resource or "mod_"..plugin..".lua"; | 39 resource = resource or "mod_"..plugin..".lua"; |
39 local lua_version = _VERSION:match(" (.+)$"); | |
40 local names = { | 40 local names = { |
41 "mod_"..plugin..dir_sep..plugin..dir_sep..resource; -- mod_hello/hello/mod_hello.lua | 41 "mod_"..plugin..dir_sep..plugin..dir_sep..resource; -- mod_hello/hello/mod_hello.lua |
42 "mod_"..plugin..dir_sep..resource; -- mod_hello/mod_hello.lua | 42 "mod_"..plugin..dir_sep..resource; -- mod_hello/mod_hello.lua |
43 plugin..dir_sep..resource; -- hello/mod_hello.lua | 43 plugin..dir_sep..resource; -- hello/mod_hello.lua |
44 resource; -- mod_hello.lua | 44 resource; -- mod_hello.lua |