0

Suppose for instance that I have two directories src and test and I want to run a command when a file changes in either of those trees. I don't want to watch their parent directory since src and test have siblings which I don't want to watch.

  • Please add more context; is the parent of these two directories a git or hg repo? Why don't you want to watch that dir? Are there other siblings that are very large or change very frequently (if so, how many files and how frequently)? Knowing the answers to these will help give the best advice – Wez Furlong Nov 15 '15 at 03:54
  • Right so imagine a package manager (in this case npm) puts a bunch of stuff (186M) in a sibling (`/node_modules`) that almost never changes. – Gareth 'Ari' Aye Nov 15 '15 at 16:48

1 Answers1

1

OK, so I think you're anticipating performance problems with node_modules. It may not be be a problem in practice (I'll refer you to https://stackoverflow.com/a/29654359/149111 for some context; the number of files and dirs impacts performance much more than the combined size of those files), so I'd suggest just watching the common root dir and see if you end up encountering warnings about recrawls.

If you do hit problems with recrawls, then the recommendation is to use the ignore_dirs configuration option.

https://facebook.github.io/watchman/docs/config.html#ignore_dirs has more information on this, but the TL;DR is that you can create a .watchmanconfig file in the common root dir with these contents:

{
   "ignore_dirs": ["node_modules"]
}

This causes the watcher not to recurse into the node_modules dir.

Community
  • 1
  • 1
Wez Furlong
  • 4,727
  • 1
  • 29
  • 34