1
0
Fork 0
mirror of synced 2024-12-21 21:51:08 -05:00

Merge branch 'dsifford/fix-clean'

This commit is contained in:
Anish Athalye 2018-08-06 20:56:11 -04:00
commit f197ededb1
2 changed files with 19 additions and 3 deletions

View file

@ -34,11 +34,11 @@ class Clean(dotbot.Plugin):
Cleans all the broken symbolic links in target if they point to Cleans all the broken symbolic links in target if they point to
a subdirectory of the base directory or if forced to clean. a subdirectory of the base directory or if forced to clean.
''' '''
if not os.path.isdir(os.path.expanduser(target)): if not os.path.isdir(os.path.expandvars(os.path.expanduser(target))):
self._log.debug('Ignoring nonexistent directory %s' % target) self._log.debug('Ignoring nonexistent directory %s' % target)
return True return True
for item in os.listdir(os.path.expanduser(target)): for item in os.listdir(os.path.expandvars(os.path.expanduser(target))):
path = os.path.join(os.path.expanduser(target), item) path = os.path.join(os.path.expandvars(os.path.expanduser(target)), item)
if not os.path.exists(path) and os.path.islink(path): if not os.path.exists(path) and os.path.islink(path):
points_at = os.path.join(os.path.dirname(path), os.readlink(path)) points_at = os.path.join(os.path.dirname(path), os.readlink(path))
if self._in_directory(path, self._context.base_directory()) or force: if self._in_directory(path, self._context.base_directory()) or force:

View file

@ -0,0 +1,16 @@
test_description='clean expands environment variables'
. '../test-lib.bash'
test_expect_success 'setup' '
ln -s ${DOTFILES}/f ~/.f
'
test_expect_success 'run' '
run_dotbot <<EOF
- clean: ["\$HOME"]
EOF
'
test_expect_success 'test' '
! test -h ~/.f
'