crowdfavorite/cf-capistrano-wordpress — pull request #1 by jondavidjohn (2013-03-07 22:09:40+00:00)
Title: make sure target is removed before link (for directories)

@ziz

Ran into an issue where we need to link into a plugin directory that already exists with an inconsequential file inside.

found that `ln -nsf` does not force directory links, only files.

~/test › mkdir target
~/test › mkdir source
~/test › touch target/file
~/test › ll
total 0
drwxr-xr-x 2 jjohnson staff 68B Mar 7 15:07 source
drwxr-xr-x 3 jjohnson staff 102B Mar 7 15:07 target
~/test › ln -nsf source target
~/test › ll
total 0
drwxr-xr-x 2 jjohnson staff 68B Mar 7 15:07 source
drwxr-xr-x 4 jjohnson staff 136B Mar 7 15:07 target
~/test › rm -rf target
~/test › ln -nsf source target
~/test › ll
total 8
drwxr-xr-x 2 jjohnson staff 68B Mar 7 15:07 source
lrwxr-xr-x 1 jjohnson staff 6B Mar 7 15:07 target -> source

Something like this would make sure directories are forced just like files.