1
0
mirror of https://github.com/go-task/task.git synced 2025-06-15 00:15:10 +02:00

feat: resolve variables in vars declarations too

This commit is contained in:
Pete Davison
2023-12-30 17:57:23 +00:00
parent bff0a0a3d4
commit 25b1966506
3 changed files with 49 additions and 6 deletions

View File

@ -71,6 +71,10 @@ func (c *Compiler) getVariables(t *ast.Task, call *ast.Call, evaluateShVars bool
newVar.Json = tr.Replace(v.Json)
newVar.Yaml = tr.Replace(v.Yaml)
newVar.Dir = v.Dir
// If the variable is a reference, we can resolve it
if newVar.Ref != "" {
newVar.Value = result.Get(newVar.Ref).Value
}
// If the variable should not be evaluated, but is nil, set it to an empty string
// This stops empty interface errors when using the templater to replace values later
if !evaluateShVars && newVar.Value == nil {