fix(vim.fs): make rm() work with symlink to a directory

This commit is contained in:
Evgeni Chasnovski
2026-02-05 12:02:54 +02:00
committed by Lewis Russell
parent c3defb4b45
commit 14c708634e
3 changed files with 44 additions and 3 deletions

View File

@@ -735,12 +735,13 @@ end
--- Remove files or directories
--- @since 13
--- @param path string Path to remove
--- @param path string Path to remove. Removes symlinks without touching the origin.
---To remove the origin, resolve explicitly with |uv.fs_realpath()|.
--- @param opts? vim.fs.rm.Opts
function M.rm(path, opts)
opts = opts or {}
local stat, err, errnm = uv.fs_stat(path)
local stat, err, errnm = uv.fs_lstat(path)
if stat then
rm(path, stat.type, opts.recursive, opts.force)
elseif not opts.force or errnm ~= 'ENOENT' then