Ensure plugin within a directory are loaded

Close #118
This commit is contained in:
Francesco Abbate 2021-03-20 16:34:00 +01:00
parent 8567f6a7ee
commit 7f50df6a2f
1 changed files with 5 additions and 8 deletions

View File

@ -546,17 +546,14 @@ end
function core.load_plugins()
local no_errors = true
for _, root_dir in ipairs {USERDIR, DATADIR} do
local files = system.list_dir(root_dir .. "/plugins")
local plugin_dir = root_dir .. "/plugins"
local files = system.list_dir(plugin_dir)
for _, filename in ipairs(files or {}) do
local basename = filename:match("(.-)%.lua$")
if basename and config[basename] ~= false then
local basename = filename:match("(.-)%.lua$") or filename
if config[basename] ~= false then
local modname = "plugins." .. basename
local ok = core.try(require, modname)
-- Normally a log line is added for each loaded plugin which is a
-- good thing. Unfortunately we load the user module before the plugins
-- so all the messages here can fill the log screen and hide an eventual
-- user module's error.
-- if ok then core.log_quiet("Loaded plugin %q", modname) end
if ok then core.log_quiet("Loaded plugin %q from %s", basename, plugin_dir) end
if not ok then
no_errors = false
end