예제 #1
0
파일: watch.go 프로젝트: Ezmyrelda/devd
// WatchPaths watches a set of paths, and broadcasts changes through reloader.
func WatchPaths(paths, excludePatterns []string, reloader livereload.Reloader, log termlog.Logger) error {
	ch := make(chan []string, 1)
	for _, path := range paths {
		modchan := make(chan modd.Mod, 1)
		err := modd.Watch([]string{path}, excludePatterns, batchTime, modchan)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				ch <- mod.All()
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}
예제 #2
0
파일: watch.go 프로젝트: Ezmyrelda/devd
// Watch watches an endpoint for changes, if it supports them.
func (r Route) Watch(ch chan []string, excludePatterns []string, log termlog.Logger) error {
	switch r.Endpoint.(type) {
	case *filesystemEndpoint:
		ep := *r.Endpoint.(*filesystemEndpoint)
		modchan := make(chan modd.Mod, 1)
		err := modd.Watch([]string{string(ep)}, excludePatterns, batchTime, modchan)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				ch <- mod.All()
			}
		}()
	}
	return nil
}