mirror of
https://github.com/go-task/task.git
synced 2025-07-17 01:43:07 +02:00
refactor isUpToDate()
This commit is contained in:
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) {
|
func (t *Task) isUpToDate(ctx context.Context) (bool, error) {
|
||||||
if len(t.Status) > 0 {
|
if len(t.Status) > 0 {
|
||||||
environ, err := t.getEnviron()
|
return t.isUpToDateStatus(ctx)
|
||||||
if err != nil {
|
}
|
||||||
return false, err
|
return t.isUpToDateTimestamp(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range t.Status {
|
func (t *Task) isUpToDateStatus(ctx context.Context) (bool, error) {
|
||||||
err = execext.RunCommand(&execext.RunCommandOptions{
|
environ, err := t.getEnviron()
|
||||||
Context: ctx,
|
if err != nil {
|
||||||
Command: s,
|
return false, err
|
||||||
Dir: t.Dir,
|
|
||||||
Env: environ,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
if len(t.Sources) == 0 || len(t.Generates) == 0 {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user