ref: b9b70fb6b085e5141078bee80f342d2a9fdc2f5e
parent: f85d1a7da25fb1d0d6491eabee2860058095fbec
author: Anthony Fok <[email protected]>
date: Tue Mar 10 12:55:23 EDT 2015
Skip directories like node_modules from the watchlist A local `node_modules` directory can easily contain tens of thousands of files, easily exhausting the tiny default max open files limit especially on OS X Yosemite, in spite of the fact that Hugo already had code in place since February 2014 to try to raise the maxfiles ulimit. Also skip `.git` and `bower_components` directories. The file watching situation will improve when https://github.com/go-fsnotify/fsevents become ready, but until then, we will be thrifty. :-) Thanks to @chibicode for the suggestion. See #168 for continued discussions.
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -292,6 +292,7 @@
return syncer.Sync(publishDir, staticDir)
}
+// getDirList provides NewWatcher() with a list of directories to watch for changes.
func getDirList() []string {
var a []string
walker := func(path string, fi os.FileInfo, err error) error {
@@ -318,6 +319,10 @@
}
if fi.IsDir() {
+ if fi.Name() == ".git" ||
+ fi.Name() == "node_modules" || fi.Name() == "bower_components" {
+ return filepath.SkipDir
+ }
a = append(a, path)
}
return nil