hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit b9b70fb6b085e5141078bee80f342d2a9fdc2f5e
parent f85d1a7da25fb1d0d6491eabee2860058095fbec
Author: Anthony Fok <foka@debian.org>
Date:   Tue, 10 Mar 2015 16:55:23 -0600

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.

Diffstat:
Mcommands/hugo.go | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/commands/hugo.go b/commands/hugo.go
@@ -292,6 +292,7 @@ func copyStatic() error {
 	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 @@ func getDirList() []string {
 		}
 
 		if fi.IsDir() {
+			if fi.Name() == ".git" ||
+				fi.Name() == "node_modules" || fi.Name() == "bower_components" {
+				return filepath.SkipDir
+			}
 			a = append(a, path)
 		}
 		return nil