1
0
mirror of https://github.com/go-task/task.git synced 2025-11-29 22:48:03 +02:00

feat: change Var.Value from string to an any type

This commit is contained in:
Pete Davison
2023-11-29 16:21:21 +00:00
parent de09e675c1
commit 5516ac1a00
5 changed files with 54 additions and 35 deletions

View File

@@ -108,6 +108,11 @@ func (e *Executor) compiledTask(call taskfile.Call, evaluateShVars bool) (*taskf
new.Env.Merge(r.ReplaceVars(origTask.Env))
if evaluateShVars {
err = new.Env.Range(func(k string, v taskfile.Var) error {
// If the variable is not dynamic, we can set it and return
if v.Value != nil || v.Sh == "" {
new.Env.Set(k, taskfile.Var{Value: v.Value})
return nil
}
static, err := e.Compiler.HandleDynamicVar(v, new.Dir)
if err != nil {
return err
@@ -149,10 +154,13 @@ func (e *Executor) compiledTask(call taskfile.Call, evaluateShVars bool) (*taskf
if cmd.For.Var != "" {
if vars != nil {
v := vars.Get(cmd.For.Var)
if cmd.For.Split != "" {
list = strings.Split(v.Value, cmd.For.Split)
} else {
list = strings.Fields(v.Value)
switch value := v.Value.(type) {
case string:
if cmd.For.Split != "" {
list = strings.Split(value, cmd.For.Split)
} else {
list = strings.Fields(value)
}
}
}
}