Plugin improvements (require vs dofile)

This commit is contained in:
Simone Mainardi 2020-07-23 19:39:28 +02:00
parent 2e16c2b76c
commit 5fe50b0fd5
2 changed files with 13 additions and 4 deletions

View file

@ -9,9 +9,12 @@ local lua_path_utils = {}
function lua_path_utils.package_path_preprend(path)
local include_path = path.."/?.lua;"
if not package.path:match(include_path) then
package.path = include_path..package.path
-- If the path is already inside package.path, we remove it, before prepending it
if not package.path:starts(include_path) and package.path:gmatch(include_path) then
package.path = package.path:gsub(include_path, '')
end
package.path = include_path..package.path
end
-- ########################################################