jekyll / jekyll-watch

:eyes: Rebuild your Jekyll site when a file changes with the `--watch` switch.
MIT License
93 stars 36 forks source link

ignore doesn't accept wildcards? #90

Open mohkale opened 4 years ago

mohkale commented 4 years ago

This is in part related to issue 7888 on the official jekyll repo.

Right now I've got an exclude section in my yaml like the following:

exclude:
  - node_modules/
  - vendor/
  - assets/ascii/*.md
  - assets/gpg/*.private.gpg
  - "*.rb"
  - "**/.#*"

The really annoying part here is that unless an absolute path for these entries exist, jekyll-watch doesn't include them in the list of paths to be ignored. see here for what I mean. Meaning even if jekyll itself won't output a hello.rb file to the build directory, jekyll-watch will rebuild the site because a path like /path/to/my/site/*.rb doesn't exist.

A secondary annoyance is that jekyll itself uses File.fnmatch? for checking if a path should be excluded, whereas Listen (I believe) uses regular expressions :(. This means that our build exclude and our watch exclude don't match properly.

My proposal is to keep what we have, add a section to the README explaining how jekyll-exclude only accepts some of the entries in our configs exclude section (exactly those for which a valid file exists) & add a new section to our configs watch_exclude consisting of regular expressions like "^\.jekyll\-metadata!" which we simply include in our ignore list altogether. This probably means there'll be some overlap between watch_exclude and exclude... but it's better than outright ignoring most of our exclude values.

A better solution would be somehow converting fnmatch paths to regular expressions or requesting that the Listen library uses fnmatch for strings and regular expressions seperately (like jekyll does at the moment).