cespare / reflex

Run a command when files change

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support shared inverse regexes

dradtke opened this issue · comments

I was running into a too many open files issue due to having a lot of stuff in my project's vendor/ folder, which was odd because my configuration specified --inverse-regex='^vendor/'. After some investigation, I realized that Reflex only excludes files from its watcher as long as it knows that all of the specified configurations should ignore that regex; if any of them don't include it explicitly, then Reflex will still walk the tree just in case something needs it. Since I use Reflex for several different purposes, I had to add --inverse-regex='^vendor/' to about 5 different lines before the issue went away, even though the rest of them include a more specific --regex that would never match a vendored file anyway.

A couple possible solutions are:

  1. Allow both a config file and command-line inverse regexes. If an inverse regex is provided as an argument, it should apply to all watchers found in the config.
  2. Update the config file syntax to support some form of reusable arguments, even if it's just environment variable expansion.

also got bit by this, im tempted to submit a pr for it. thanks for the workaround @dradtke

There also does not appear to be an easy way to see how many files are being watched, and which files they are. It would be awesome to have a flag to have reflex log the watch list, as well as a way of knowing it's limits.

@awildeep if you use the verbose flag (-v) it outputs files as they change to stdout.

Example:

reflex -r '.go' -d fancy -v go build
Globals set at commandline
| --decoration (-d) 'fancy' (default: 'plain')
| --regex (-r) '[.go]' (default: '[]')
| --verbose (-v) 'true' (default: 'false')
+---------
Reflex from [commandline]
| ID: 0
| Inverted regex match: "(^|/)\\.git/"
| Inverted regex match: "(^|/)\\.hg/"
| Inverted regex match: "~$"
| Inverted regex match: "\\.swp$"
| Inverted regex match: "\\.#"
| Inverted regex match: "(^|/)#.*#$"
| Inverted regex match: "(^|/)\\.DS_Store$"
| Regex match: ".go"
| Substitution symbol {}
| Command: [go build]
+---------

[info] fsnotify event: "web.go": REMOVE
[info] fsnotify event: "web.go": CREATE
[info] fsnotify event: "web.go~": CREATE
[info] fsnotify event: "web.go": RENAME
[info] fsnotify event: "web.go": CREATE
[info] fsnotify event: "web.go": CHMOD