2022-12-03 14:31:21 +00:00
|
|
|
local Config = require("lazy.core.config")
|
2023-10-09 10:25:42 +01:00
|
|
|
local Util = require("lazy.util")
|
2022-11-28 21:03:44 +00:00
|
|
|
|
|
|
|
---@type table<string, LazyTaskDef>
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.clean = {
|
2022-12-03 14:31:21 +00:00
|
|
|
skip = function(plugin)
|
|
|
|
return plugin._.is_local
|
|
|
|
end,
|
2022-11-28 21:03:44 +00:00
|
|
|
run = function(self)
|
|
|
|
local dir = self.plugin.dir:gsub("/+$", "")
|
2022-12-03 14:48:06 +00:00
|
|
|
assert(dir:find(Config.options.root, 1, true) == 1, self.plugin.dir .. " should be under packpath!")
|
2022-11-28 21:03:44 +00:00
|
|
|
|
2022-12-03 14:31:21 +00:00
|
|
|
local stat = vim.loop.fs_lstat(dir)
|
2024-01-19 15:09:28 +00:00
|
|
|
assert(stat and stat.type == "directory", self.plugin.dir .. " should be a directory!")
|
2022-11-28 21:03:44 +00:00
|
|
|
|
2022-12-03 14:31:21 +00:00
|
|
|
Util.walk(dir, function(path, _, type)
|
|
|
|
if type == "directory" then
|
|
|
|
vim.loop.fs_rmdir(path)
|
2022-11-28 21:03:44 +00:00
|
|
|
else
|
2022-12-03 14:31:21 +00:00
|
|
|
vim.loop.fs_unlink(path)
|
2022-11-28 21:03:44 +00:00
|
|
|
end
|
2022-12-03 14:31:21 +00:00
|
|
|
end)
|
|
|
|
vim.loop.fs_rmdir(dir)
|
|
|
|
|
|
|
|
self.plugin._.installed = false
|
2022-11-28 21:03:44 +00:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
|
|
|
return M
|