示例#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
}