Skip to content

Commit

Permalink
Skip directories like node_modules from the watchlist
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
anthonyfok committed Mar 10, 2015
1 parent f85d1a7 commit b9b70fb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit b9b70fb

Please sign in to comment.