fix(rocks): better errors / warnings when something goes wrong with luarocks

This commit is contained in:
Folke Lemaitre 2024-06-25 13:23:25 +02:00
parent 9005e8ede7
commit 7d3f69104f
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
11 changed files with 336 additions and 141 deletions

View file

@ -1,5 +1,6 @@
local Config = require("lazy.core.config")
local Loader = require("lazy.core.loader")
local Rocks = require("lazy.pkg.rockspec")
local Util = require("lazy.util")
---@type table<string, LazyTaskDef>
@ -16,52 +17,6 @@ end
local B = {}
---@param task LazyTask
function B.rockspec(task)
---@type table<string, string>
local env = {}
local luarocks = "luarocks"
if Config.options.rocks.hererocks then
local is_win = jit.os:find("Windows")
local sep = is_win and ";" or ":"
local hererocks = Config.options.rocks.root .. "/hererocks/bin"
if is_win then
hererocks = hererocks:gsub("/", "\\")
end
local path = vim.split(vim.env.PATH, sep)
table.insert(path, 1, hererocks)
env = {
PATH = table.concat(path, sep),
}
if is_win then
luarocks = luarocks .. ".bat"
end
local plugin = Config.plugins.hererocks
-- hererocks is still building, so skip for now
if plugin and plugin._.build then
return
end
end
local root = Config.options.rocks.root .. "/" .. task.plugin.name
task:spawn(luarocks, {
args = {
"--tree",
root,
"--server",
Config.options.rocks.server,
"--dev",
"--lua-version",
"5.1",
"make",
"--force-fast",
},
cwd = task.plugin.dir,
env = env,
})
end
---@param task LazyTask
---@param build string
function B.cmd(task, build)
@ -114,7 +69,7 @@ M.build = {
build(self.plugin)
end)
elseif build == "rockspec" then
B.rockspec(self)
Rocks.build(self)
elseif build:sub(1, 1) == ":" then
B.cmd(self, build)
elseif build:match("%.lua$") then