From 08addde1d95a1c1594975b1aedabb3aa01e06a15 Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Sun, 20 Jan 2019 13:34:56 -0400 Subject: [PATCH] Support templating --- dotdrop/installer.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dotdrop/installer.py b/dotdrop/installer.py index 9f7aa23..7e9ebad 100644 --- a/dotdrop/installer.py +++ b/dotdrop/installer.py @@ -120,9 +120,27 @@ class Installer: results = [] for i in range(len(children)): - result = self._link(srcs[i], dsts[i], actions) + src = srcs[i] + dst = dsts[i] + + if Templategen.is_template(src): + if self.debug: + self.log.dbg('dotfile is a template') + self.log.dbg('install to {} and symlink' + .format(self.workdir)) + tmp = self._pivot_path(dst, self.workdir, striphome=True) + i = self.install(templater, src, tmp, actions=actions) + if not i and not os.path.exists(tmp): + continue + src = tmp + + result = self._link(src, dst, actions) + + # Empty actions if dotfile installed + # This prevents from running actions multiple times if len(result): actions = [] + results.append(result) return utils.flatten(results)