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

feat: support refs in dependencies

This commit is contained in:
Pete Davison
2023-12-30 18:10:20 +00:00
parent 25b1966506
commit dbc120c970
3 changed files with 35 additions and 4 deletions

View File

@ -234,6 +234,17 @@ func (e *Executor) compiledTask(call ast.Call, evaluateShVars bool) (*ast.Task,
newDep := dep.DeepCopy()
newDep.Task = r.Replace(dep.Task)
newDep.Vars = r.ReplaceVars(dep.Vars)
// Loop over the dep's variables and resolve any references to other variables
err := dep.Vars.Range(func(k string, v ast.Var) error {
if v.Ref != "" {
refVal := vars.Get(v.Ref)
newDep.Vars.Set(k, refVal)
}
return nil
})
if err != nil {
return nil, err
}
new.Deps = append(new.Deps, newDep)
}
}