diff options
author | Anish Athalye <me@anishathalye.com> | 2018-08-06 20:56:11 -0400 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2018-08-06 20:56:11 -0400 |
commit | f197ededb11e7613aa0f4c5f88311e9ab4653749 (patch) | |
tree | 8148b583de5c3492398979d55067bee9a53c6e93 | |
parent | f95cbe2705ce851b37b868ba3047f5789e7d433e (diff) | |
parent | 9332cde5ad5c7ab27483b63f61f1a8de6836743a (diff) |
Merge branch 'dsifford/fix-clean'
-rw-r--r-- | dotbot/plugins/clean.py | 6 | ||||
-rw-r--r-- | test/tests/clean-environment-variable-expansion.bash | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/dotbot/plugins/clean.py b/dotbot/plugins/clean.py index 7e6cba1..22c975e 100644 --- a/dotbot/plugins/clean.py +++ b/dotbot/plugins/clean.py @@ -34,11 +34,11 @@ class Clean(dotbot.Plugin): Cleans all the broken symbolic links in target if they point to 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) return True - for item in os.listdir(os.path.expanduser(target)): - path = os.path.join(os.path.expanduser(target), item) + for item in os.listdir(os.path.expandvars(os.path.expanduser(target))): + path = os.path.join(os.path.expandvars(os.path.expanduser(target)), item) if not os.path.exists(path) and os.path.islink(path): points_at = os.path.join(os.path.dirname(path), os.readlink(path)) if self._in_directory(path, self._context.base_directory()) or force: diff --git a/test/tests/clean-environment-variable-expansion.bash b/test/tests/clean-environment-variable-expansion.bash new file mode 100644 index 0000000..fedab45 --- /dev/null +++ b/test/tests/clean-environment-variable-expansion.bash @@ -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 +' |