Skip to content

Commit 540e458

Browse files
committed
refactor isUpToDate()
1 parent b530cba commit 540e458

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

task.go

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,32 @@ func (e *Executor) runDeps(ctx context.Context, task string) error {
132132

133133
func (t *Task) isUpToDate(ctx context.Context) (bool, error) {
134134
if len(t.Status) > 0 {
135-
environ, err := t.getEnviron()
136-
if err != nil {
137-
return false, err
138-
}
135+
return t.isUpToDateStatus(ctx)
136+
}
137+
return t.isUpToDateTimestamp(ctx)
138+
}
139139

140-
for _, s := range t.Status {
141-
err = execext.RunCommand(&execext.RunCommandOptions{
142-
Context: ctx,
143-
Command: s,
144-
Dir: t.Dir,
145-
Env: environ,
146-
})
147-
if err != nil {
148-
return false, nil
149-
}
140+
func (t *Task) isUpToDateStatus(ctx context.Context) (bool, error) {
141+
environ, err := t.getEnviron()
142+
if err != nil {
143+
return false, err
144+
}
145+
146+
for _, s := range t.Status {
147+
err = execext.RunCommand(&execext.RunCommandOptions{
148+
Context: ctx,
149+
Command: s,
150+
Dir: t.Dir,
151+
Env: environ,
152+
})
153+
if err != nil {
154+
return false, nil
150155
}
151-
return true, nil
152156
}
157+
return true, nil
158+
}
153159

160+
func (t *Task) isUpToDateTimestamp(ctx context.Context) (bool, error) {
154161
if len(t.Sources) == 0 || len(t.Generates) == 0 {
155162
return false, nil
156163
}

0 commit comments

Comments
 (0)