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

Remove ignore_errors

This commit is contained in:
Stephen Prater
2019-05-28 13:02:59 -07:00
parent 659cae6a4c
commit 044d3a0ff9
7 changed files with 39 additions and 95 deletions

View File

@@ -10,16 +10,12 @@ import (
)
var (
// ErrNecessaryPreconditionFailed is returned when a precondition fails
ErrNecessaryPreconditionFailed = errors.New("task: precondition not met")
// ErrOptionalPreconditionFailed is returned when a precondition fails
// that has ignore_error set to true
ErrOptionalPreconditionFailed = errors.New("task: optional precondition not met")
// ErrPreconditionFailed is returned when a precondition fails
ErrPreconditionFailed = errors.New("task: precondition not met")
)
func (e *Executor) areTaskPreconditionsMet(ctx context.Context, t *taskfile.Task) (bool, error) {
var optionalPreconditionFailed bool
for _, p := range t.Precondition {
for _, p := range t.Preconditions {
err := execext.RunCommand(ctx, &execext.RunCommandOptions{
Command: p.Sh,
Dir: t.Dir,
@@ -28,17 +24,9 @@ func (e *Executor) areTaskPreconditionsMet(ctx context.Context, t *taskfile.Task
if err != nil {
e.Logger.Outf(p.Msg)
if p.IgnoreError == true {
optionalPreconditionFailed = true
} else {
return false, ErrNecessaryPreconditionFailed
}
return false, ErrPreconditionFailed
}
}
if optionalPreconditionFailed == true {
return true, ErrOptionalPreconditionFailed
}
return true, nil
}