Skip to content

Commit b73c57e

Browse files
committed
fix(luarocks): cleanup luarocks when deleting a plugin
1 parent 368747b commit b73c57e

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

lua/lazy/manage/task/fs.lua

+18-11
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,32 @@ local Util = require("lazy.util")
44
---@type table<string, LazyTaskDef>
55
local M = {}
66

7+
local function rm(dir)
8+
local stat = vim.uv.fs_lstat(dir)
9+
assert(stat and stat.type == "directory", dir .. " should be a directory!")
10+
Util.walk(dir, function(path, _, type)
11+
if type == "directory" then
12+
vim.uv.fs_rmdir(path)
13+
else
14+
vim.uv.fs_unlink(path)
15+
end
16+
end)
17+
vim.uv.fs_rmdir(dir)
18+
end
19+
720
M.clean = {
821
skip = function(plugin)
922
return plugin._.is_local
1023
end,
1124
run = function(self)
1225
local dir = self.plugin.dir:gsub("/+$", "")
1326
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
27+
rm(dir)
1428

15-
local stat = vim.uv.fs_lstat(dir)
16-
assert(stat and stat.type == "directory", self.plugin.dir .. " should be a directory!")
17-
18-
Util.walk(dir, function(path, _, type)
19-
if type == "directory" then
20-
vim.uv.fs_rmdir(path)
21-
else
22-
vim.uv.fs_unlink(path)
23-
end
24-
end)
25-
vim.uv.fs_rmdir(dir)
29+
local rock_root = Config.options.rocks.root .. "/" .. self.plugin.name
30+
if vim.uv.fs_stat(rock_root) then
31+
rm(rock_root)
32+
end
2633

2734
self.plugin._.installed = false
2835
end,

0 commit comments

Comments
 (0)