1
0
mirror of https://github.com/go-task/task.git synced 2025-11-23 22:24:45 +02:00

fix: watch interval (#970)

This commit is contained in:
Pete Davison
2022-12-31 10:48:49 -06:00
committed by GitHub
parent c7d9efebf9
commit 796097e3ab
5 changed files with 17 additions and 30 deletions

View File

@@ -38,23 +38,14 @@ func (e *Executor) watchTasks(calls ...taskfile.Call) error {
}()
}
var watchIntervalString string
if e.Interval != "" {
watchIntervalString = e.Interval
} else if e.Taskfile.Interval != "" {
watchIntervalString = e.Taskfile.Interval
}
watchInterval := defaultWatchInterval
if watchIntervalString != "" {
var err error
watchInterval, err = parseWatchInterval(watchIntervalString)
if err != nil {
cancel()
return err
}
var watchInterval time.Duration
switch {
case e.Interval != 0:
watchInterval = e.Interval
case e.Taskfile.Interval != 0:
watchInterval = e.Taskfile.Interval
default:
watchInterval = defaultWatchInterval
}
e.Logger.VerboseOutf(logger.Green, "task: Watching for changes every %v", watchInterval)
@@ -186,11 +177,3 @@ func (e *Executor) registerWatchedFiles(w *watcher.Watcher, calls ...taskfile.Ca
func shouldIgnoreFile(path string) bool {
return strings.Contains(path, "/.git") || strings.Contains(path, "/.task") || strings.Contains(path, "/node_modules")
}
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)
}
return v, nil
}