fix: interpolate vars in defer (#1814)

Co-authored-by: Andrey Nering <andreynering@users.noreply.github.com>
This commit is contained in:
Valentin Maerten
2024-09-19 03:17:53 +02:00
committed by GitHub
parent 0be05795b9
commit 1bf850592c
3 changed files with 14 additions and 5 deletions

View File

@@ -324,8 +324,13 @@ func (e *Executor) runDeferred(t *ast.Task, call *ast.Call, i int, deferredExitC
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
origTask, err := e.GetTask(call)
if err != nil {
return
}
cmd := t.Cmds[i]
vars, _ := e.Compiler.FastGetVariables(t, call)
vars, _ := e.Compiler.FastGetVariables(origTask, call)
cache := &templater.Cache{Vars: vars}
extra := map[string]any{}