Abort clean when a plugin spec fails to parse
An unparseable entry dropped out of the wanted set, so clean deleted the directory and lock entry of a plugin the user still has configured. Add tests/init_spec.lua covering setup, sync, clean and list.
This commit is contained in:
+10
-1
@@ -119,7 +119,16 @@ function M.sync(opts)
|
||||
end
|
||||
|
||||
function M.clean()
|
||||
local specs = spec_mod.parse_all(M.config.plugins)
|
||||
local specs, errors = spec_mod.parse_all(M.config.plugins)
|
||||
for _, err in ipairs(errors) do
|
||||
notify(err, vim.log.levels.ERROR)
|
||||
end
|
||||
-- An unparseable entry still names a plugin the user wants, so the set of
|
||||
-- wanted names is incomplete; deleting from it would remove a live install.
|
||||
if #errors > 0 then
|
||||
return notify('clean aborted, no plugin spec may be in error', vim.log.levels.WARN)
|
||||
end
|
||||
|
||||
local wanted = {}
|
||||
for _, spec in ipairs(specs) do
|
||||
wanted[spec.name] = true
|
||||
|
||||
Reference in New Issue
Block a user