mirror of
https://github.com/go-task/task.git
synced 2025-12-16 11:47:44 +01:00
fix: support error_ignore for a task call (#2552)
This commit is contained in:
8
task.go
8
task.go
@@ -311,10 +311,12 @@ func (e *Executor) runCommand(ctx context.Context, t *ast.Task, call *Call, i in
|
|||||||
defer reacquire()
|
defer reacquire()
|
||||||
|
|
||||||
err := e.RunTask(ctx, &Call{Task: cmd.Task, Vars: cmd.Vars, Silent: cmd.Silent, Indirect: true})
|
err := e.RunTask(ctx, &Call{Task: cmd.Task, Vars: cmd.Vars, Silent: cmd.Silent, Indirect: true})
|
||||||
if err != nil {
|
var exitCode interp.ExitStatus
|
||||||
return err
|
if errors.As(err, &exitCode) && cmd.IgnoreError {
|
||||||
|
e.Logger.VerboseErrf(logger.Yellow, "task: [%s] task error ignored: %v\n", t.Name(), err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return err
|
||||||
case cmd.Cmd != "":
|
case cmd.Cmd != "":
|
||||||
if !shouldRunOnCurrentPlatform(cmd.Platforms) {
|
if !shouldRunOnCurrentPlatform(cmd.Platforms) {
|
||||||
e.Logger.VerboseOutf(logger.Yellow, "task: [%s] %s not for current platform - ignored\n", t.Name(), cmd.Cmd)
|
e.Logger.VerboseOutf(logger.Yellow, "task: [%s] %s not for current platform - ignored\n", t.Name(), cmd.Cmd)
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ func (c *Cmd) UnmarshalYAML(node *yaml.Node) error {
|
|||||||
c.Vars = cmdStruct.Vars
|
c.Vars = cmdStruct.Vars
|
||||||
c.For = cmdStruct.For
|
c.For = cmdStruct.For
|
||||||
c.Silent = cmdStruct.Silent
|
c.Silent = cmdStruct.Silent
|
||||||
|
c.IgnoreError = cmdStruct.IgnoreError
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user