stakx-io / stakx

An opinionated, powerful, and simple static website generator built in PHP
https://stakx.io/
MIT License
14 stars 3 forks source link

Include regexes don’t supersede exclude in config #118

Open PeterMedina opened 4 years ago

PeterMedina commented 4 years ago

System Information

PHP Version:

7.4.1

stakx Version:

v0.2.0-beta1-19-g719042b

Operating System

macOS 10.15.2

Expected behavior

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.

allejo commented 4 years ago

I've added a failing test in 4d5f46c484512b1751be8b9e0758539efe2b8aaf.

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?