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

Method Watch

watch.go:15–48  ·  view source on GitHub ↗

Watch watches an endpoint for changes, if it supports them.

(
	ch chan []string,
	excludePatterns []string,
	log termlog.Logger,
)

Source from the content-addressed store, hash-verified

13
14// Watch watches an endpoint for changes, if it supports them.
15func (r Route) Watch(
16 ch chan []string,
17 excludePatterns []string,
18 log termlog.Logger,
19) (*moddwatch.Watcher, error) {
20 wd, err := os.Getwd()
21 if err != nil {
22 return nil, err
23 }
24 var watcher *moddwatch.Watcher
25 switch r.Endpoint.(type) {
26 case *filesystemEndpoint:
27 ep := *r.Endpoint.(*filesystemEndpoint)
28 modchan := make(chan *moddwatch.Mod, 1)
29 watcher, err = moddwatch.Watch(
30 wd,
31 []string{ep.Root + "/...", "**"},
32 excludePatterns,
33 batchTime,
34 modchan,
35 )
36 if err != nil {
37 return nil, err
38 }
39 go func() {
40 for mod := range modchan {
41 if !mod.Empty() {
42 ch <- mod.All()
43 }
44 }
45 }()
46 }
47 return watcher, nil
48}
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 {

Callers

nothing calls this directly

Calls 1

WatchMethod · 0.65

Tested by

no test coverage detected