diff --git a/lua/dep/fs.lua b/lua/dep/fs.lua index fb307e0..02a799a 100644 --- a/lua/dep/fs.lua +++ b/lua/dep/fs.lua @@ -38,17 +38,23 @@ function fs:clean(package) while handle do local name = h.uv.fs_scandir_next(handle) - if name then + if name and name ~= package.get_root().name then queue[name] = package.get_base_dir().."/"..name + elseif name == package.get_root().name then + -- we need to ensure that there is no chance of nuking dep + goto continue + elseif name == nil then + break else -- if there's a single error bail out logger:log("error", "failed to run clean uv.fs_scandir_next failed") return end + ::continue:: end -- keep packages that still exist - for _, pkg in ipairs(package.get_packages()) do + for _, pkg in pairs(package.get_packages()) do queue[pkg.name] = nil end