Пример #1
0
// 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 {
		absPath, err := filepath.Abs(path)
		if err != nil {
			return err
		}
		if absPath[len(absPath)-1] != filepath.Separator {
			absPath += string(filepath.Separator)
		}

		pathchan := make(chan []string, 1)
		err = watch.Watch(path, batchTime, pathchan)
		if err != nil {
			return err
		}
		go func() {
			for files := range pathchan {
				files = filterFiles(absPath, files, excludePatterns, log)
				if len(files) > 0 {
					ch <- files
				}
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}
Пример #2
0
// WatchRoutes watches the route collection, and broadcasts changes through reloader.
func WatchRoutes(routes RouteCollection, reloader livereload.Reloader, excludePatterns []string, log termlog.Logger) error {
	c := make(chan []string, 1)
	for i := range routes {
		err := routes[i].Watch(c, excludePatterns, log)
		if err != nil {
			return err
		}
	}
	go reloader.Watch(c)
	return nil
}
Пример #3
0
// 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
}
Пример #4
0
// 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(path, batchTime, modchan)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				files := filterFiles(mod.All(), excludePatterns, log)
				if len(files) > 0 {
					ch <- files
				}
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}
Пример #5
0
// 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 *moddwatch.Mod, 1)
		_, err := moddwatch.Watch([]string{path}, batchTime, modchan)
		if err != nil {
			return err
		}
		go func() {
			for mod := range modchan {
				filteredMod, err := mod.Filter([]string{"**/*"}, excludePatterns)
				if err != nil {
					log.Shout("Error filtering watches: %s", err)
				}
				if !filteredMod.Empty() {
					ch <- filteredMod.All()
				}
			}
		}()
	}
	go reloader.Watch(ch)
	return nil
}