1
0
mirror of https://github.com/go-task/task.git synced 2025-01-06 03:53:54 +02:00

Re-run the task if generated files do not exist

This commit is contained in:
Seiichi Uchida 2019-08-01 12:51:27 +09:00
parent 4c295b564a
commit 26e0c0887a
2 changed files with 20 additions and 8 deletions

View File

@ -14,10 +14,11 @@ import (
// Checksum validades if a task is up to date by calculating its source
// files checksum
type Checksum struct {
Dir string
Task string
Sources []string
Dry bool
Dir string
Task string
Sources []string
Generates []string
Dry bool
}
// IsUpToDate implements the Checker interface
@ -32,6 +33,16 @@ func (c *Checksum) IsUpToDate() (bool, error) {
return false, err
}
generates, err := glob(c.Dir, c.Generates)
if err != nil || len(generates) == 0 {
return false, err
}
for _, generate := range generates {
if _, err := os.Stat(generate); err != nil {
return false, nil
}
}
newMd5, err := c.checksum(sources...)
if err != nil {
return false, nil

View File

@ -58,10 +58,11 @@ func (e *Executor) getStatusChecker(t *taskfile.Task) (status.Checker, error) {
}, nil
case "checksum":
return &status.Checksum{
Dir: t.Dir,
Task: t.Task,
Sources: t.Sources,
Dry: e.Dry,
Dir: t.Dir,
Task: t.Task,
Sources: t.Sources,
Generates: t.Generates,
Dry: e.Dry,
}, nil
case "none":
return status.None{}, nil