mirror of
https://github.com/go-task/task.git
synced 2024-12-04 10:24:45 +02:00
247c2586c2
* refactor: ast package * feat: read -> taskfile * refactor: taskfile.Taskfile -> taskfile.Read * refactor: move merge function back into taskfile package * refactor: rename taskfile.go to read.go
36 lines
678 B
Go
36 lines
678 B
Go
package task
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/go-task/task/v3/errors"
|
|
"github.com/go-task/task/v3/taskfile/ast"
|
|
)
|
|
|
|
func (e *Executor) areTaskRequiredVarsSet(ctx context.Context, t *ast.Task, call ast.Call) error {
|
|
if t.Requires == nil || len(t.Requires.Vars) == 0 {
|
|
return nil
|
|
}
|
|
|
|
vars, err := e.Compiler.GetVariables(t, call)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
var missingVars []string
|
|
for _, requiredVar := range t.Requires.Vars {
|
|
if !vars.Exists(requiredVar) {
|
|
missingVars = append(missingVars, requiredVar)
|
|
}
|
|
}
|
|
|
|
if len(missingVars) > 0 {
|
|
return &errors.TaskMissingRequiredVars{
|
|
TaskName: t.Name(),
|
|
MissingVars: missingVars,
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|