1
0
mirror of https://github.com/go-task/task.git synced 2025-04-23 12:18:57 +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

@ -17,6 +17,7 @@ type Checksum struct {
Dir string
Task string
Sources []string
Generates []string
Dry bool
}
@ -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

@ -61,6 +61,7 @@ func (e *Executor) getStatusChecker(t *taskfile.Task) (status.Checker, error) {
Dir: t.Dir,
Task: t.Task,
Sources: t.Sources,
Generates: t.Generates,
Dry: e.Dry,
}, nil
case "none":