Open cwick opened 10 years ago
The glob syntax should support negative glob patterns, like !(special.coffee|very_special.coffee)
, thanks to the minimatch library. Does this help?
Sadly this does not work. Instead broccoli throws an error because glob returns zero matched patterns. See line 221 of broccoli-kitchen-sink-helpers/index.js. This is because standard glob negation does not work with node-glob by default.
From the node-glob README:
If the pattern starts with a ! character, then it is negated. Set the nonegate flag to suppress this behavior, and treat leading ! characters normally. This is perhaps relevant if you wish to start the pattern with a negative extglob pattern like !(a|B). Multiple ! characters at the start of a pattern will negate the pattern multiple times.
Setting nonegate: true solves the problem. I have made the relevant pull request for helpers, please merge it if this is how you want patterns to work in broccoli. Otherwise, please advise how we can achieve match exclusion with the default glob nonegate: false.
Ah yes, I think this is hitting a specific case where negation doesn't work properly: https://github.com/isaacs/node-glob/issues/62
I'm still unsure how to best evolve the static-compiler syntax, but in this particular case it seems the node-glob should be fixed to make it work.
You could also try using https://github.com/rjackson/broccoli-file-remover for this purpose.
isaacs/node-glob#62 seems to be fixed now.
I just created a quick form which uses grunt.file.expand() rather than helpers.multiGlob(), which allows this. It passes the few tests that exists, but I don't really know enough about the expected behaviour of this plugin to say if my fork is a solid fix.
If there's any interest, check it out at https://github.com/stefanfisk/broccoli-static-compiler and let me know.
Also need this feature
It would be useful if the
files
glob supported excluding files that match a pattern. See https://github.com/anodynos/node-glob-expand for examples.In my project, I have all
.coffee
files in the same directory, but one.coffee
file needs special processing. It would be nice to say:Currently I work around it by putting special files in their own directory, or messing with file extensions or file name patterns.