MCPcopy
hub / github.com/go-task/task / areTaskPreconditionsMet

Method areTaskPreconditionsMet

precondition.go:16–32  ·  view source on GitHub ↗
(ctx context.Context, t *ast.Task)

Source from the content-addressed store, hash-verified

14var ErrPreconditionFailed = errors.New("task: precondition not met")
15
16func (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}

Callers 1

RunTaskMethod · 0.95

Calls 4

RunCommandFunction · 0.92
GetFunction · 0.92
IsFunction · 0.92
ErrfMethod · 0.80

Tested by

no test coverage detected