1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

fix: don't report errors when fast compiling

This commit is contained in:
Pete Davison
2023-12-23 04:41:59 +00:00
parent dfe39bfb5d
commit d87e7981fb

View File

@@ -199,31 +199,19 @@ func (e *Executor) compiledTask(call ast.Call, evaluateShVars bool) (*ast.Task,
if len(keys) > 0 { if len(keys) > 0 {
extra["KEY"] = keys[i] extra["KEY"] = keys[i]
} }
new.Cmds = append(new.Cmds, &ast.Cmd{ newCmd := cmd.DeepCopy()
Cmd: r.ReplaceWithExtra(cmd.Cmd, extra), newCmd.Cmd = r.ReplaceWithExtra(cmd.Cmd, extra)
Task: r.ReplaceWithExtra(cmd.Task, extra), newCmd.Task = r.ReplaceWithExtra(cmd.Task, extra)
Silent: cmd.Silent, newCmd.Vars = r.ReplaceVarsWithExtra(cmd.Vars, extra)
Set: cmd.Set, new.Cmds = append(new.Cmds, newCmd)
Shopt: cmd.Shopt,
Vars: r.ReplaceVarsWithExtra(cmd.Vars, extra),
IgnoreError: cmd.IgnoreError,
Defer: cmd.Defer,
Platforms: cmd.Platforms,
})
} }
continue continue
} }
new.Cmds = append(new.Cmds, &ast.Cmd{ newCmd := cmd.DeepCopy()
Cmd: r.Replace(cmd.Cmd), newCmd.Cmd = r.Replace(cmd.Cmd)
Task: r.Replace(cmd.Task), newCmd.Task = r.Replace(cmd.Task)
Silent: cmd.Silent, newCmd.Vars = r.ReplaceVars(cmd.Vars)
Set: cmd.Set, new.Cmds = append(new.Cmds, newCmd)
Shopt: cmd.Shopt,
Vars: r.ReplaceVars(cmd.Vars),
IgnoreError: cmd.IgnoreError,
Defer: cmd.Defer,
Platforms: cmd.Platforms,
})
} }
} }
if len(origTask.Deps) > 0 { if len(origTask.Deps) > 0 {
@@ -232,24 +220,23 @@ func (e *Executor) compiledTask(call ast.Call, evaluateShVars bool) (*ast.Task,
if dep == nil { if dep == nil {
continue continue
} }
new.Deps = append(new.Deps, &ast.Dep{ newDep := dep.DeepCopy()
Task: r.Replace(dep.Task), newDep.Task = r.Replace(dep.Task)
Vars: r.ReplaceVars(dep.Vars), newDep.Vars = r.ReplaceVars(dep.Vars)
Silent: dep.Silent, new.Deps = append(new.Deps, newDep)
})
} }
} }
if len(origTask.Preconditions) > 0 { if len(origTask.Preconditions) > 0 {
new.Preconditions = make([]*ast.Precondition, 0, len(origTask.Preconditions)) new.Preconditions = make([]*ast.Precondition, 0, len(origTask.Preconditions))
for _, precond := range origTask.Preconditions { for _, precondition := range origTask.Preconditions {
if precond == nil { if precondition == nil {
continue continue
} }
new.Preconditions = append(new.Preconditions, &ast.Precondition{ newPrecondition := precondition.DeepCopy()
Sh: r.Replace(precond.Sh), newPrecondition.Sh = r.Replace(precondition.Sh)
Msg: r.Replace(precond.Msg), newPrecondition.Msg = r.Replace(precondition.Msg)
}) new.Preconditions = append(new.Preconditions, newPrecondition)
} }
} }
@@ -272,7 +259,12 @@ func (e *Executor) compiledTask(call ast.Call, evaluateShVars bool) (*ast.Task,
new.Status = r.ReplaceSlice(origTask.Status) new.Status = r.ReplaceSlice(origTask.Status)
} }
return &new, r.Err() // We only care about templater errors if we are evaluating shell variables
if evaluateShVars && r.Err() != nil {
return &new, r.Err()
}
return &new, nil
} }
func asAnySlice[T any](slice []T) []any { func asAnySlice[T any](slice []T) []any {