1
0
Fork 0
mirror of synced 2024-12-21 21:51:08 -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,6 +37,7 @@ class Link(dotbot.Plugin):
if create: if create:
success &= self._create(destination) success &= self._create(destination)
if force or relink: if force or relink:
if self._exists(path):
success &= self._delete(path, destination, relative, force) success &= self._delete(path, destination, relative, force)
success &= self._link(path, destination, relative) success &= self._link(path, destination, relative)
if success: if success:

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
'