Make force only delete files when target exists
This commit is contained in:
parent
913d5484ca
commit
b482cbda58
2 changed files with 26 additions and 1 deletions
|
@ -37,7 +37,8 @@ class Link(dotbot.Plugin):
|
||||||
if create:
|
if create:
|
||||||
success &= self._create(destination)
|
success &= self._create(destination)
|
||||||
if force or relink:
|
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)
|
success &= self._link(path, destination, relative)
|
||||||
if success:
|
if success:
|
||||||
self._log.info('All links have been set up')
|
self._log.info('All links have been set up')
|
||||||
|
|
24
test/tests/link-force-leaves-when-nonexistent.bash
Normal file
24
test/tests/link-force-leaves-when-nonexistent.bash
Normal 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
|
||||||
|
'
|
Loading…
Reference in a new issue