1
0
Fork 0
mirror of synced 2024-11-16 21:45:35 -05:00

Make force only delete files when target exists

This commit is contained in:
Anish Athalye 2016-11-17 14:12:22 -05:00
parent 913d5484ca
commit b482cbda58
2 changed files with 26 additions and 1 deletions

View file

@ -37,7 +37,8 @@ class Link(dotbot.Plugin):
if create:
success &= self._create(destination)
if force or relink:
success &= self._delete(path, destination, relative, force)
if self._exists(path):
success &= self._delete(path, destination, relative, force)
success &= self._link(path, destination, relative)
if success:
self._log.info('All links have been set up')

View file

@ -0,0 +1,24 @@
test_description='force leaves file when target nonexistent'
. '../test-lib.bash'
test_expect_success 'setup' '
mkdir ~/dir &&
touch ~/file
'
test_expect_failure 'run' '
run_dotbot <<EOF
- link:
~/dir:
path: dir
force: true
~/file:
path: file
force: true
EOF
'
test_expect_success 'test' '
test -d ~/dir &&
test -f ~/file
'