-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't clean broken symbolic links #99
Comments
antonionoca
added a commit
to antonionoca/grunt-contrib-clean
that referenced
this issue
Oct 14, 2017
Using fs.unlink to remove symlink if exists. Added test.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce:
ln -s nonexists alink
.nonexists
is a non-existing file.cleanBrokenLink: ['alink']
and run it. The output should be:ls -l alink
output:alink -> nonexists
, showing thatalink
is not cleaned.Note that broken symlinks could show up easily when cleaning a dir containing symlinks: if a link target was removed before the link is tried to remove, the link becomes broken.
Root cause:
clean()
intasks/clean.js
tests a filepath withgrunt.file.exists()
before trying to remove it, butgrunt.file.exists()
returnfalse
for a broken symbolic link (because offs.exists()
it calling), soclean()
skips to remove it.Possible solution: replace
grunt.file.exists()
with afs.lstatSync()
based solution, because it doesn't follow links. Additionally,grunt.file.isPathInCwd()
also suffers from broken-symbolic-link problem.The text was updated successfully, but these errors were encountered: