github.com/zhb127/air@v0.0.2-0.20231109030911-fb911e430cdd/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 }