mirror of
1
0
Fork 0

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
'