mirror of
https://github.com/go-task/task.git
synced 2025-03-17 21:08:01 +02:00
refactor isUpToDate()
This commit is contained in:
parent
b530cba0d5
commit
540e458b16
39
task.go
39
task.go
@ -132,25 +132,32 @@ func (e *Executor) runDeps(ctx context.Context, task string) error {
|
||||
|
||||
func (t *Task) isUpToDate(ctx context.Context) (bool, error) {
|
||||
if len(t.Status) > 0 {
|
||||
environ, err := t.getEnviron()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return t.isUpToDateStatus(ctx)
|
||||
}
|
||||
return t.isUpToDateTimestamp(ctx)
|
||||
}
|
||||
|
||||
for _, s := range t.Status {
|
||||
err = execext.RunCommand(&execext.RunCommandOptions{
|
||||
Context: ctx,
|
||||
Command: s,
|
||||
Dir: t.Dir,
|
||||
Env: environ,
|
||||
})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
func (t *Task) isUpToDateStatus(ctx context.Context) (bool, error) {
|
||||
environ, err := t.getEnviron()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, s := range t.Status {
|
||||
err = execext.RunCommand(&execext.RunCommandOptions{
|
||||
Context: ctx,
|
||||
Command: s,
|
||||
Dir: t.Dir,
|
||||
Env: environ,
|
||||
})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (t *Task) isUpToDateTimestamp(ctx context.Context) (bool, error) {
|
||||
if len(t.Sources) == 0 || len(t.Generates) == 0 {
|
||||
return false, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user