1 local t_concat
= table.concat
;
3 local path_sep
= package
.config
:sub(1,1);
7 -- Helper function to resolve relative paths (needed by config)
8 function path_util
.resolve_relative_path(parent_path
, path
)
11 parent_path
= parent_path
:gsub("%"..path_sep
.."+$", "");
12 path
= path
:gsub("^%.%"..path_sep
.."+", "");
15 if path_sep
== "/" and path
:sub(1,1) ~= "/" then
17 elseif path_sep
== "\\" and (path
:sub(1,1) ~= "/" and (path
:sub(2,3) ~= ":\\" and path
:sub(2,3) ~= ":/")) then
21 return parent_path
..path_sep
..path
;
27 -- Helper function to convert a glob to a Lua pattern
28 function path_util
.glob_to_pattern(glob
)
29 return "^"..glob
:gsub("[%p*?]", function (c
)
40 function path_util
.join(...)
41 return t_concat({...}, path_sep
);
44 function path_util
.complement_lua_path(installer_plugin_path
)
45 -- Checking for duplicates
46 -- The commands using luarocks need the path to the directory that has the /share and /lib folders.
47 local lua_version
= _VERSION
:match(" (.+)$");
48 local lua_path_sep
= package
.config
:sub(3,3);
49 local dir_sep
= package
.config
:sub(1,1);
50 local sub_path
= dir_sep
.."lua"..dir_sep
..lua_version
..dir_sep
;
51 if not string.match(package
.path
, installer_plugin_path
) then
52 package
.path
= package
.path
..lua_path_sep
..installer_plugin_path
..dir_sep
.."share"..sub_path
.."?.lua";
53 package
.path
= package
.path
..lua_path_sep
..installer_plugin_path
..dir_sep
.."share"..sub_path
.."?"..dir_sep
.."init.lua";
55 if not string.match(package
.path
, installer_plugin_path
) then
56 package
.cpath
= package
.cpath
..lua_path_sep
..installer_plugin_path
..dir_sep
.."lib"..sub_path
.."?.so";