diff --git a/task_test.go b/task_test.go index ca3e02d8..1b131f07 100644 --- a/task_test.go +++ b/task_test.go @@ -1503,9 +1503,6 @@ Hello, World! assert.NoError(t, e.Setup()) buff.Reset() - ctx := context.Background() - ctx, cancel := context.WithCancel(ctx) - err := os.MkdirAll(dir+"/src", 0755) assert.NoError(t, err) @@ -1514,6 +1511,9 @@ Hello, World! t.Fatal(err) } + ctx := context.Background() + ctx, cancel := context.WithCancel(ctx) + go func(ctx context.Context) { for { select { @@ -1535,9 +1535,10 @@ Hello, World! } time.Sleep(70 * time.Millisecond) cancel() - assert.Equal(t, expectedOutput, strings.TrimSpace(buff.String())) buff.Reset() err = os.RemoveAll(dir + "/.task") assert.NoError(t, err) + err = os.RemoveAll(dir + "/src") + assert.NoError(t, err) } diff --git a/testdata/watcher_interval/Taskfile.yaml b/testdata/watcher_interval/Taskfile.yaml index 23c2d069..2a1e16b8 100644 --- a/testdata/watcher_interval/Taskfile.yaml +++ b/testdata/watcher_interval/Taskfile.yaml @@ -5,7 +5,7 @@ version: '3' vars: GREETING: Hello, World! -interval: "50ms" +interval: "30ms" tasks: default: diff --git a/watch.go b/watch.go index c75d225c..60ac6aae 100644 --- a/watch.go +++ b/watch.go @@ -39,17 +39,17 @@ func (e *Executor) watchTasks(calls ...taskfile.Call) error { var watchIntervalString string - if e.Taskfile.Interval != "" { - watchIntervalString = e.Taskfile.Interval - } else if e.Interval != "" { + if e.Interval != "" { watchIntervalString = e.Interval + } else if e.Taskfile.Interval != "" { + watchIntervalString = e.Taskfile.Interval } watchInterval := defaultWatchInterval if watchIntervalString != "" { var err error - watchInterval, err = parsedWatchInterval(watchIntervalString) + watchInterval, err = parseWatchInterval(watchIntervalString) if err != nil { e.Logger.Errf(logger.Red, "%v", err) } @@ -185,7 +185,7 @@ func shouldIgnoreFile(path string) bool { return strings.Contains(path, "/.git") || strings.Contains(path, "/.task") || strings.Contains(path, "/node_modules") } -func parsedWatchInterval(watchInterval string) (time.Duration, error) { +func parseWatchInterval(watchInterval string) (time.Duration, error) { v, err := time.ParseDuration(watchInterval) if err != nil { return 0, fmt.Errorf(`task: Could not parse watch interval "%s": %v`, watchInterval, err)