Skip to content
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

Unlink symlinked directory target #30

Open
maherbeg opened this issue Aug 9, 2013 · 6 comments
Open

Unlink symlinked directory target #30

maherbeg opened this issue Aug 9, 2013 · 6 comments

Comments

@maherbeg
Copy link

maherbeg commented Aug 9, 2013

When a clean is invoked on a symlinked folder, the symlink still appears in the folder but in a broken state. Could the clean target automatically unlink the folder?

Would something like this make more sense as a user filter? If so, could examples using symlinks be shown as well?

Thanks!

@arcanis
Copy link

arcanis commented Dec 23, 2013

Up. Contrib clean is currently not able to delete symlinks. Maybe adding an option would be enough without breaking BC ?

@dazld
Copy link

dazld commented Jan 15, 2014

also want this.

@jamesplease
Copy link
Member

Update: I'm thinking this might be relevant. When I made a working symlink it cleaned just fine. Here's an example that will create a symlink that can be removed, and one that can't.

If this is the case, the issue is more a matter of reporting bad symlinks.


What OS are y'all using?

I'm working on a fix for this for OSX. Here's what I know so far:

grunt-contrib-clean is just a wrapper around isaac's rimraf, and rimraf has no problem deleting symlinks. So the issue is with grunt-contrib-clean, or maybe even node.

The first problem is this if statement. grunt.file.exists relies on fs.exists, which seems to return false for symlinks – or at least the symlink that I've made. I'm thinking this check can be removed altogether. (Note: ref this issue which suggests that exists should work for symlinks)

The second issue is this line. grunt.file.isPathInCwd depends on fs.realpath, which throws the following error when I pass my symlink's path as the argument:

Error: ELOOP, too many symbolic links encountered

I thought that this might be relevant, but it's only throwing the error with the node function. Everything else seems a-okay.

If anyone else has any ideas, feel free to chime in. Otherwise I'll look more into this sometime soon.


Note to self: using fs.lstatSync(filepath).isSymbolicLink() could be useful.

@vladikoff
Copy link
Member

@jmeas is this related to gruntjs/grunt#1069 ?

@jamesplease
Copy link
Member

Only as far as them both involving symlinks. This is a bug with bad symlinks, I think, and that's adding new functionality to grunt.

@vladikoff
Copy link
Member

@jmeas ah both involve changes to the grunt.file module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants