MCPcopy
hub / github.com/cortesi/devd / WatchPaths

Function WatchPaths

watch.go:51–79  ·  view source on GitHub ↗

WatchPaths watches a set of paths, and broadcasts changes through reloader.

(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger)

Source from the content-addressed store, hash-verified

49
50// WatchPaths watches a set of paths, and broadcasts changes through reloader.
51func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
52 wd, err := os.Getwd()
53 if err != nil {
54 return err
55 }
56 ch := make(chan []string, 1)
57 for _, path := range paths {
58 modchan := make(chan *moddwatch.Mod, 1)
59 _, err := moddwatch.Watch(
60 wd,
61 []string{path},
62 excludePatterns,
63 batchTime,
64 modchan,
65 )
66 if err != nil {
67 return err
68 }
69 go func() {
70 for mod := range modchan {
71 if !mod.Empty() {
72 ch <- mod.All()
73 }
74 }
75 }()
76 }
77 go reloader.Watch(ch)
78 return nil
79}
80
81// WatchRoutes watches the route collection, and broadcasts changes through reloader.
82func WatchRoutes(routes RouteCollection, reloader livereload.Reloader, excludePatterns []string, log termlog.Logger) error {

Callers 1

RouterMethod · 0.85

Calls 1

WatchMethod · 0.65

Tested by

no test coverage detected