cespare / reflex

Run a command when files change

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Intelligently limit watches to certain directories

cespare opened this issue · comments

It's quite common for people to run into open file limits problems because their working directory has a subdirectory with a giant tree in it. (Today's example was a node_modules dir.) There are workarounds listed at https://github.com/cespare/reflex#open-file-limits, but we could also do better directly without adding any other flags.

As I mentioned in #29 (comment), we could do something like this:

If the user passes something like -g api/*.py, instead of watching ./ and filtering against api/*.py, we can watch ./api/ and filter against *.py.

This can be extended to multiple globs and even regexps, where we can extract prefix directories.

If the user passes -g api/*.py -g tests/foo/bar/*.py, reflex can issue two watches, one in ./api/ and one in ./tests/foo/bar/.

In this way, we can automatically watch the most specific directories possible.

There are many caveats here, including:

  • We need to be careful about overlapping watches causing duplicates
  • Inverse matches need to be adjusted