1
0
mirror of https://github.com/go-task/task.git synced 2025-11-25 22:32:55 +02:00

Add --status flag to check is a task is up-to-date

Closes #81
This commit is contained in:
Andrey Nering
2017-12-26 21:43:52 -02:00
parent dfd890c8a6
commit 78f6cb08d8
3 changed files with 30 additions and 0 deletions

View File

@@ -8,6 +8,24 @@ import (
"github.com/go-task/task/internal/status"
)
// Status returns an error if any the of given tasks is not up-to-date
func (e *Executor) Status(calls ...Call) error {
for _, call := range calls {
t, ok := e.Tasks[call.Task]
if !ok {
return &taskNotFoundError{taskName: call.Task}
}
isUpToDate, err := t.isUpToDate(e.Context)
if err != nil {
return err
}
if !isUpToDate {
return fmt.Errorf(`task: Task "%s" is not up-to-date`, t.Task)
}
}
return nil
}
func (t *Task) isUpToDate(ctx context.Context) (bool, error) {
if len(t.Status) > 0 {
return t.isUpToDateStatus(ctx)