Comparison

util/pluginloader.lua @ 13831:bf4cd327966f

Merge 13.0->trunk
author Matthew Wild <mwild1@gmail.com>
date Wed, 09 Apr 2025 10:59:28 +0100
parent 13829:dde0ce03049b
comparison
equal deleted inserted replaced
13826:53eb500b19a4 13831:bf4cd327966f
23 local pluginloader_mt = { __index = pluginloader_methods }; 23 local pluginloader_mt = { __index = pluginloader_methods };
24 24
25 function pluginloader_methods:load_file(names) 25 function pluginloader_methods:load_file(names)
26 local file, err, path; 26 local file, err, path;
27 local load_filter_cb = self._options.load_filter_cb; 27 local load_filter_cb = self._options.load_filter_cb;
28 local last_filter_path, last_filter_err;
28 for i=1,#plugin_dir do 29 for i=1,#plugin_dir do
29 for j=1,#names do 30 for j=1,#names do
30 path = plugin_dir[i]..names[j]; 31 path = plugin_dir[i]..names[j];
31 file, err = io_open(path); 32 file, err = io_open(path);
32 if file then 33 if file then
34 file:close(); 35 file:close();
35 local metadata; 36 local metadata;
36 if load_filter_cb then 37 if load_filter_cb then
37 path, content, metadata = load_filter_cb(path, content); 38 path, content, metadata = load_filter_cb(path, content);
38 end 39 end
39 if content and path then 40 if path and content then
40 return content, path, metadata; 41 return content, path, metadata;
42 else
43 last_filter_path = plugin_dir[i]..names[j];
44 last_filter_err = content or "skipped";
41 end 45 end
42 end 46 end
43 end 47 end
48 end
49 if last_filter_err then
50 return nil, err..(" (%s skipped because of %s)"):format(last_filter_path, last_filter_err);
44 end 51 end
45 return file, err; 52 return file, err;
46 end 53 end
47 54
48 function pluginloader_methods:load_resource(plugin, resource) 55 function pluginloader_methods:load_resource(plugin, resource)