From a548c63a923b67c8befc4d923e1de5feac9c0260 Mon Sep 17 00:00:00 2001 From: Sindre Myren Date: Sun, 9 Jul 2017 23:37:50 +0200 Subject: [PATCH] Bugfix: allow templating when calling deps Fixes issue #42 by allowing for template evaluatation on task override variables when the task is launched as dependency. --- task.go | 10 +++++++++- task_test.go | 1 + testdata/params/Taskfile.yml | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/task.go b/task.go index b330bda6..2621ac13 100644 --- a/task.go +++ b/task.go @@ -165,8 +165,16 @@ func (e *Executor) runDeps(ctx context.Context, call Call) error { if err != nil { return err } + depVars := make(Vars, len(d.Vars)) + for k, v := range d.Vars { + v, err := e.ReplaceVariables(v, call) + if err != nil { + return err + } + depVars[k] = v + } - return e.RunTask(ctx, Call{Task: dep, Vars: d.Vars}) + return e.RunTask(ctx, Call{Task: dep, Vars: depVars}) }) } diff --git a/task_test.go b/task_test.go index a5277731..f7c3db50 100644 --- a/task_test.go +++ b/task_test.go @@ -179,6 +179,7 @@ func TestParams(t *testing.T) { {"dep1.txt", "Dependence1\n"}, {"dep2.txt", "Dependence2\n"}, {"spanish.txt", "¡Holla mundo!\n"}, + {"spanish-dep.txt", "¡Holla dependencia!\n"}, } for _, f := range files { diff --git a/testdata/params/Taskfile.yml b/testdata/params/Taskfile.yml index 150441ea..ddc11925 100644 --- a/testdata/params/Taskfile.yml +++ b/testdata/params/Taskfile.yml @@ -6,6 +6,8 @@ default: vars: {CONTENT: Dependence1, FILE: dep1.txt} - task: write-file vars: {CONTENT: Dependence2, FILE: dep2.txt} + - task: write-file + vars: {CONTENT: "{{.SPANISH|replace \"mundo\" \"dependencia\"}}", FILE: spanish-dep.txt} cmds: - task: write-file vars: {CONTENT: Hello, FILE: hello.txt}