1
0
mirror of https://github.com/go-task/task.git synced 2025-03-29 21:57:04 +02:00

Merge pull request from smyrman/issue-42

Bugfix: allow templating when calling deps
This commit is contained in:
Andrey Nering 2017-07-09 20:02:39 -03:00 committed by GitHub
commit a586fef414
3 changed files with 12 additions and 1 deletions

10
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})
})
}

@ -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 {

@ -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}