Make force only delete files when target exists

pull/106/head v1.9.4
Anish Athalye 7 years ago
parent 913d5484ca
commit b482cbda58
  1. 3
      plugins/link.py
  2. 24
      test/tests/link-force-leaves-when-nonexistent.bash

@ -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')

@ -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
'
Loading…
Cancel
Save