sindresorhus / trash

Move files and directories to the trash
MIT License
2.57k stars 78 forks source link

Trash symlinks #59

Closed jdalton closed 7 years ago

jdalton commented 7 years ago

Under the hood trash uses an approximation of fs.exists(symlink) which will return false and so skip trashing symlinks.

sindresorhus commented 7 years ago

I just tested it on some symlinks and trash works, and fs.existsSync() returns true.

jdalton commented 7 years ago

Hmm interesting, thanks! Sorry about that. I've already changed to removing the parent directory. If I run into it again I'll re-ping.

Ninir commented 7 years ago

Hey folks,

Just ran into this issue, but another case. Here is the testcase:

$ mkdir test
$ cd test 
$ mkdir foo bar
$ touch bar/dev.tpl
$ cd foo 
$ ln -s ../bar/dev.tpl 
$ mv ../bar ../baz
$ ls -la
total 8
drwxr-xr-x  3 jeanbon  wheel  102 Jul 25 11:43 .
drwxr-xr-x  4 jeanbon  wheel  136 Jul 25 11:43 ..
lrwxr-xr-x  1 jeanbon  wheel   14 Jul 25 11:43 dev.tpl -> ../bar/dev.tpl
$ rm dev.tpl
$ ls -la
total 8
drwxr-xr-x  3 jeanbon  wheel  102 Jul 25 11:43 .
drwxr-xr-x  4 jeanbon  wheel  136 Jul 25 11:43 ..
lrwxr-xr-x  1 jeanbon  wheel   14 Jul 25 11:43 dev.tpl -> ../bar/dev.tpl

Meta

OS: macOs Sierra Native Terminal App + ZSH