fix(pkg): correctly pre-load package specs and remove them when needed during resolve

This commit is contained in:
Folke Lemaitre 2024-06-23 17:49:19 +02:00
parent d7bc9ce11a
commit 93552cd18e
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
6 changed files with 87 additions and 38 deletions

View file

@ -29,24 +29,27 @@ function M.get(plugin)
end
---@type RockSpec?
---@diagnostic disable-next-line: missing-fields
local rockspec = {}
local ret, err = loadfile(rockspec_file, "t", rockspec)
if not ret then
local load, err = loadfile(rockspec_file, "t", rockspec)
if not load then
error(err)
end
ret()
return rockspec
and rockspec.package
load()
---@param dep string
local rocks = vim.tbl_filter(function(dep)
local name = dep:gsub("%s.*", "")
return not vim.tbl_contains(M.skip, name)
end, rockspec and rockspec.dependencies or {})
return #rocks > 0
and {
source = "rockspec",
file = rockspec_file,
spec = {
dir = plugin.dir,
url = plugin.url,
rocks = vim.tbl_filter(function(dep)
local name = dep:gsub("%s.*", "")
return not vim.tbl_contains(M.skip, name)
end, rockspec.dependencies),
plugin.name,
rocks = rocks,
},
}
or nil