mirror of https://github.com/folke/lazy.nvim.git
fix(luarocks): cleanup luarocks when deleting a plugin
This commit is contained in:
parent
368747bc9a
commit
b73c57ed9e
|
@ -4,6 +4,19 @@ local Util = require("lazy.util")
|
||||||
---@type table<string, LazyTaskDef>
|
---@type table<string, LazyTaskDef>
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
local function rm(dir)
|
||||||
|
local stat = vim.uv.fs_lstat(dir)
|
||||||
|
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)
|
||||||
|
else
|
||||||
|
vim.uv.fs_unlink(path)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
vim.uv.fs_rmdir(dir)
|
||||||
|
end
|
||||||
|
|
||||||
M.clean = {
|
M.clean = {
|
||||||
skip = function(plugin)
|
skip = function(plugin)
|
||||||
return plugin._.is_local
|
return plugin._.is_local
|
||||||
|
@ -11,18 +24,12 @@ M.clean = {
|
||||||
run = function(self)
|
run = function(self)
|
||||||
local dir = self.plugin.dir:gsub("/+$", "")
|
local dir = self.plugin.dir:gsub("/+$", "")
|
||||||
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
|
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
|
||||||
|
rm(dir)
|
||||||
|
|
||||||
local stat = vim.uv.fs_lstat(dir)
|
local rock_root = Config.options.rocks.root .. "/" .. self.plugin.name
|
||||||
assert(stat and stat.type == "directory", self.plugin.dir .. " should be a directory!")
|
if vim.uv.fs_stat(rock_root) then
|
||||||
|
rm(rock_root)
|
||||||
Util.walk(dir, function(path, _, type)
|
end
|
||||||
if type == "directory" then
|
|
||||||
vim.uv.fs_rmdir(path)
|
|
||||||
else
|
|
||||||
vim.uv.fs_unlink(path)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
vim.uv.fs_rmdir(dir)
|
|
||||||
|
|
||||||
self.plugin._.installed = false
|
self.plugin._.installed = false
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue