feat(rockspec): scan rockspecs directory for .rockspec files

This commit is contained in:
infastin 2025-01-14 23:11:08 +05:00
parent d8f26efd45
commit a17180d7a9

View file

@ -247,17 +247,36 @@ end
---@param plugin LazyPlugin ---@param plugin LazyPlugin
function M.find_rockspec(plugin) function M.find_rockspec(plugin)
local rockspec_file ---@type string? local rockspec_file ---@type string?
local check_file = function(path, name)
for _, suffix in ipairs({ "scm", "git", "dev" }) do
suffix = suffix .. "-1.rockspec"
if name:sub(-#suffix) == suffix then
return path
end
end
end
Util.ls(plugin.dir, function(path, name, t) Util.ls(plugin.dir, function(path, name, t)
if t == "file" then if t == "directory" and name == "rockspecs" then
for _, suffix in ipairs({ "scm", "git", "dev" }) do Util.ls(path, function(path, name, t)
suffix = suffix .. "-1.rockspec" rockspec_file = check_file(path, name)
if name:sub(-#suffix) == suffix then if rockspec_file ~= nil then
rockspec_file = path
return false return false
end end
end)
if rockspec_file ~= nil then
return false
end
end
if t == "file" then
rockspec_file = check_file(path, name)
if rockspec_file ~= nil then
return false
end end
end end
end) end)
return rockspec_file return rockspec_file
end end
@ -311,11 +330,13 @@ function M.get(plugin)
-- has a complex build process -- has a complex build process
or not M.is_simple_build(rockspec) or not M.is_simple_build(rockspec)
rockspec_file = rockspec_file:sub(#plugin.dir+2)
if not use then if not use then
-- community specs only -- community specs only
return #specs > 0 return #specs > 0
and { and {
file = vim.fn.fnamemodify(rockspec_file, ":t"), file = rockspec_file,
spec = { spec = {
plugin.name, plugin.name,
specs = specs, specs = specs,
@ -331,7 +352,7 @@ function M.get(plugin)
end end
return { return {
file = vim.fn.fnamemodify(rockspec_file, ":t"), file = rockspec_file,
spec = { spec = {
plugin.name, plugin.name,
build = "rockspec", build = "rockspec",