mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 18:34:48 +00:00
fix dotfile src/dst not expanded with ext variables (#177)
This commit is contained in:
@@ -214,11 +214,23 @@ class CfgYaml:
|
||||
|
||||
def _resolve_dotfile_paths(self):
|
||||
"""resolve dotfile paths"""
|
||||
t = Templategen(variables=self.variables)
|
||||
|
||||
for dotfile in self.dotfiles.values():
|
||||
# src
|
||||
src = dotfile[self.key_dotfile_src]
|
||||
new = t.generate_string(src)
|
||||
if new != src and self.debug:
|
||||
self.log.dbg('dotfile: {} -> {}'.format(src, new))
|
||||
src = new
|
||||
src = os.path.join(self.settings[self.key_settings_dotpath], src)
|
||||
dotfile[self.key_dotfile_src] = self._norm_path(src)
|
||||
# dst
|
||||
dst = dotfile[self.key_dotfile_dst]
|
||||
new = t.generate_string(dst)
|
||||
if new != dst and self.debug:
|
||||
self.log.dbg('dotfile: {} -> {}'.format(dst, new))
|
||||
dst = new
|
||||
dotfile[self.key_dotfile_dst] = self._norm_path(dst)
|
||||
|
||||
def _rec_resolve_vars(self, variables):
|
||||
@@ -292,15 +304,6 @@ class CfgYaml:
|
||||
"""template any needed parts of the config"""
|
||||
t = Templategen(variables=self.variables)
|
||||
|
||||
# dotfiles src/dst/actions keys
|
||||
for k, v in self.dotfiles.items():
|
||||
# src
|
||||
src = v.get(self.key_dotfile_src)
|
||||
v[self.key_dotfile_src] = t.generate_string(src)
|
||||
# dst
|
||||
dst = v.get(self.key_dotfile_dst)
|
||||
v[self.key_dotfile_dst] = t.generate_string(dst)
|
||||
|
||||
# import_actions
|
||||
new = []
|
||||
entries = self.settings.get(self.key_import_actions, [])
|
||||
|
||||
@@ -78,10 +78,14 @@ dotfiles:
|
||||
f_abc:
|
||||
dst: ${tmpd}/abc
|
||||
src: abc
|
||||
f_def:
|
||||
dst: ${tmpd}/{{@@ theprofile @@}}
|
||||
src: def
|
||||
profiles:
|
||||
p1:
|
||||
dotfiles:
|
||||
- f_abc
|
||||
- f_def
|
||||
variables:
|
||||
varx: profvarx
|
||||
provar: provar
|
||||
@@ -107,6 +111,8 @@ echo "evar1: {{@@ evar1 @@}}" >> ${tmps}/dotfiles/abc
|
||||
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
|
||||
echo "theprofile: {{@@ theprofile @@}}" >> ${tmps}/dotfiles/abc
|
||||
|
||||
echo "theprofile: {{@@ theprofile @@}}" > ${tmps}/dotfiles/def
|
||||
|
||||
#cat ${tmps}/dotfiles/abc
|
||||
|
||||
# install
|
||||
@@ -123,6 +129,10 @@ grep '^evar1: extevar1' ${tmpd}/abc >/dev/null
|
||||
grep '^provar: provar' ${tmpd}/abc >/dev/null
|
||||
grep '^theprofile: p1' ${tmpd}/abc >/dev/null
|
||||
|
||||
# check def
|
||||
[ ! -e ${tmpd}/p1 ] && echo "def not created" && exit 1
|
||||
grep '^theprofile: p1' ${tmpd}/p1 >/dev/null
|
||||
|
||||
rm -f ${tmpd}/abc
|
||||
|
||||
#cat ${tmpd}/abc
|
||||
|
||||
Reference in New Issue
Block a user