(ctx context.Context, t *ast.Task)
| 14 | var ErrPreconditionFailed = errors.New("task: precondition not met") |
| 15 | |
| 16 | func (e *Executor) areTaskPreconditionsMet(ctx context.Context, t *ast.Task) (bool, error) { |
| 17 | for _, p := range t.Preconditions { |
| 18 | err := execext.RunCommand(ctx, &execext.RunCommandOptions{ |
| 19 | Command: p.Sh, |
| 20 | Dir: t.Dir, |
| 21 | Env: env.Get(t), |
| 22 | }) |
| 23 | if err != nil { |
| 24 | if !errors.Is(err, context.Canceled) { |
| 25 | e.Logger.Errf(logger.Magenta, "task: %s\n", p.Msg) |
| 26 | } |
| 27 | return false, ErrPreconditionFailed |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | return true, nil |
| 32 | } |
no test coverage detected