stakx-io/stakx

Include regexes don’t supersede exclude in config

Opened this issue · 1 comments

System Information

PHP Version:

7.4.1

stakx Version:

v0.2.0-beta1-19-g719042b

Operating System

macOS 10.15.2

Expected behavior

  • I added dist to exclude: in _config.yml
  • I added /dist\/(css|fonts|images|js)\/.+/ to include: in _config.yml

I expected it to exclude everything in the dist folder except for the files included in the includes regex

Actual behavior

The desired contents of the dist folder were not copied over to the Stakx build; the dist folder itself was not included.

Steps to reproduce behavior

  1. Create a folder called dist with sub-folders of css, images and include a CSS file and a few images into their respective folders
  2. Add dist to the excludes list in _config.yml
  3. Add /dist\/(css|images)\/.+/ to the includes list in _config.yml
  4. Build Stakx

The dist folder will not be included in the build.

I've added a failing test in 4d5f46c.

The problem is that since FileExplorer short circuits any time it finds an excluded directory, it will not traverse inside of it meaning any regular expressions defined in include won't ever be matched. Explicit file paths in include are just a "copy if exists" behavior and doesn't need to match things.

I'm not sure whether or not this should be fixed. If it is fixed, how should it be fixed without introducing performance issues? Should I add support for including folders and explicitly traversing those?