github.com/bilpay-tech/air@v0.0.0-20230514155040-b55f770a4ac6/runner/watcher.go (about)

     1  package runner
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/gohugoio/hugo/watcher/filenotify"
     7  )
     8  
     9  func newWatcher(cfg *Config) (filenotify.FileWatcher, error) {
    10  	if !cfg.Build.Poll {
    11  		return filenotify.NewEventWatcher()
    12  	}
    13  
    14  	// Get the poll interval from the config.
    15  	interval := cfg.Build.PollInterval
    16  
    17  	// Make sure the interval is at least 500ms.
    18  	if interval < 500 {
    19  		interval = 500
    20  	}
    21  	pollInterval := time.Duration(interval) * time.Millisecond
    22  
    23  	return filenotify.NewPollingWatcher(pollInterval), nil
    24  }