diff options
author | Anish Athalye <me@anishathalye.com> | 2018-11-19 20:38:59 -0500 |
---|---|---|
committer | Anish Athalye <me@anishathalye.com> | 2018-11-19 20:38:59 -0500 |
commit | b35462ab951243bb69e6c4cb2b2b0e465efcf823 (patch) | |
tree | 7f3dfc9385a49162fdd97ba03f48d7eac7824001 | |
parent | e35b0794fde7d2f0957626cafe6e08709c0fc56b (diff) | |
parent | 1be9f7532b535675f1e79f4eb96adf45a0de811b (diff) |
Merge branch 'qubidt/default-link-conditional'
-rw-r--r-- | dotbot/plugins/link.py | 9 | ||||
-rw-r--r-- | test/tests/link-if.bash | 19 |
2 files changed, 24 insertions, 4 deletions
diff --git a/dotbot/plugins/link.py b/dotbot/plugins/link.py index bf1c5a9..2506237 100644 --- a/dotbot/plugins/link.py +++ b/dotbot/plugins/link.py @@ -30,12 +30,10 @@ class Link(dotbot.Plugin): relink = defaults.get('relink', False) create = defaults.get('create', False) use_glob = defaults.get('glob', False) + test = defaults.get('if', None) if isinstance(source, dict): # extended config - test = source.get('if') - if test is not None and not self._test_success(test): - self._log.lowinfo('Skipping %s' % destination) - continue + test = source.get('if', test) relative = source.get('relative', relative) force = source.get('force', force) relink = source.get('relink', relink) @@ -44,6 +42,9 @@ class Link(dotbot.Plugin): path = self._default_source(destination, source.get('path')) else: path = self._default_source(destination, source) + if test is not None and not self._test_success(test): + self._log.lowinfo('Skipping %s' % destination) + continue path = os.path.expandvars(os.path.expanduser(path)) if use_glob: self._log.debug("Globbing with path: " + str(path)) diff --git a/test/tests/link-if.bash b/test/tests/link-if.bash index 9fe6429..1ea7709 100644 --- a/test/tests/link-if.bash +++ b/test/tests/link-if.bash @@ -30,3 +30,22 @@ grep "apple" ~/.f && grep "apple" ~/.h && ! test -f ~/.i ' + +test_expect_success 'run 2' ' +run_dotbot <<EOF +- defaults: + link: + if: "false" +- link: + ~/.j: + path: f + if: "true" + ~/.k: + path: f +EOF +' + +test_expect_success 'test 2' ' +grep "apple" ~/.j && +! test -f ~/.k +' |