fix(luarocks): cleanup luarocks when deleting a plugin

This commit is contained in:
Folke Lemaitre 2024-06-24 14:27:29 +02:00
parent 368747bc9a
commit b73c57ed9e
1 changed files with 18 additions and 11 deletions

View File

@ -4,17 +4,9 @@ local Util = require("lazy.util")
---@type table<string, LazyTaskDef>
local M = {}
M.clean = {
skip = function(plugin)
return plugin._.is_local
end,
run = function(self)
local dir = self.plugin.dir:gsub("/+$", "")
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
local function rm(dir)
local stat = vim.uv.fs_lstat(dir)
assert(stat and stat.type == "directory", self.plugin.dir .. " should be a directory!")
assert(stat and stat.type == "directory", dir .. " should be a directory!")
Util.walk(dir, function(path, _, type)
if type == "directory" then
vim.uv.fs_rmdir(path)
@ -23,6 +15,21 @@ M.clean = {
end
end)
vim.uv.fs_rmdir(dir)
end
M.clean = {
skip = function(plugin)
return plugin._.is_local
end,
run = function(self)
local dir = self.plugin.dir:gsub("/+$", "")
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
rm(dir)
local rock_root = Config.options.rocks.root .. "/" .. self.plugin.name
if vim.uv.fs_stat(rock_root) then
rm(rock_root)
end
self.plugin._.installed = false
end,