Skip to content

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Sep 7, 2023

Fixes #225

This PR adds native support for negating a glob pattern in Task. e.g.

version: '3' tasks: css: sources: - 'mysources/**/*.css' - '!mysources/ignoreme.css' generates: - 'public/bundle.css'

It works by looping over an array of patterns in order. If a pattern is normal, the files are added to a map with a value of true (i.e. the files should be included). if a pattern begins with a !, then all the files matched by that pattern are added to (or updated in) the map with a value of false (i.e. they should not be included). We then loop through the map and convert all keys with a value of true into a slice. This slice is then sorted and returned.

@pd93 pd93 mentioned this pull request Sep 7, 2023
@krystian-panek-vmltech
Copy link

krystian-panek-vmltech commented Sep 7, 2023

I just tested it. thank you @pd93

It works like a charm <3 however the '!' needs special care as it is special character in YML. without it it is possible to encounter:

image

https://stackoverflow.com/a/22235064

my working example:

 aem:build: desc: build AEM application using Maven sources: - pom.xml - all/pom.xml - all/src/**/* - core/pom.xml - core/src/**/* - ui.apps/pom.xml - ui.apps/src/**/* - '!ui.apps/src/main/content/jcr_root/apps/mysite/clientlibs/clientlib-{site,dependencies}/**/*' - ui.apps.structure/pom.xml - ui.apps.structure/src/**/* - ui.config/pom.xml - ui.config/src/**/* - ui.content/pom.xml - ui.content/src/**/* - ui.frontend/pom.xml - ui.frontend/*.js - ui.frontend/*.json - '!ui.frontend/package-lock.json' - ui.frontend/src/**/* 

I hope it will be released soon ;)

Copy link
Member

@andreynering andreynering left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid YAML issues with ! we could move to a proper key like not:, ignore: or exclude:. What do you think?

version: '3' tasks: css: sources: - mysources/**/*.css - exclude: mysources/ignoreme.css generates: - public/bundle.css

I think I would chose exclude:, but I'm open to opinions.

@krystian-panek-vmltech
Copy link

krystian-panek-vmltech commented Sep 8, 2023

yep, it's nice ;) also opting for exclude

@krystian-panek-vmltech
Copy link

can't wait to see it released ;) @andreynering

@leaanthony
Copy link
Contributor

Yeah, exclude: is great 👍

@andreynering
Copy link
Member

Hey @pd93,

Can you change to use exclude:? Once done, we're ready to merge this.

@krystian-panek-vmltech
Copy link

@pd93 any chance that you will do it this month? :) From my perspective it's pretty annoying and I would be glad to have it improved. If you have no time to complete this, just let me know I will improve it.

Co-authored-by: Andrey Nering <andrey@nering.com.br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants