Skip to content

Commit a548c63

Browse files
committed
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.
1 parent 5268df6 commit a548c63

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

task.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,16 @@ func (e *Executor) runDeps(ctx context.Context, call Call) error {
165165
if err != nil {
166166
return err
167167
}
168+
depVars := make(Vars, len(d.Vars))
169+
for k, v := range d.Vars {
170+
v, err := e.ReplaceVariables(v, call)
171+
if err != nil {
172+
return err
173+
}
174+
depVars[k] = v
175+
}
168176

169-
return e.RunTask(ctx, Call{Task: dep, Vars: d.Vars})
177+
return e.RunTask(ctx, Call{Task: dep, Vars: depVars})
170178
})
171179
}
172180

task_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ func TestParams(t *testing.T) {
179179
{"dep1.txt", "Dependence1\n"},
180180
{"dep2.txt", "Dependence2\n"},
181181
{"spanish.txt", "¡Holla mundo!\n"},
182+
{"spanish-dep.txt", "¡Holla dependencia!\n"},
182183
}
183184

184185
for _, f := range files {

testdata/params/Taskfile.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ default:
66
vars: {CONTENT: Dependence1, FILE: dep1.txt}
77
- task: write-file
88
vars: {CONTENT: Dependence2, FILE: dep2.txt}
9+
- task: write-file
10+
vars: {CONTENT: "{{.SPANISH|replace \"mundo\" \"dependencia\"}}", FILE: spanish-dep.txt}
911
cmds:
1012
- task: write-file
1113
vars: {CONTENT: Hello, FILE: hello.txt}

0 commit comments

Comments
 (0)