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:
33
watch.go
33
watch.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user