Negative glob not working as expected
See original GitHub issueHello,
I think I noticed issue with negative glob 🤔
Files structures looks like this:
foo/foo.html
bar/bar.html
gulpfile.js
Here goes the task
const {src, dest} = require('gulp');
module.exports.default = () => src(['**/*.html', '!bar/']).pipe(dest('dest'));
After running this task dest
dir contains bar
.
I expected dest
dir not to include bar
.
I made repl.it for this issue https://repl.it/@plesiecki/InvolvedIndianredProgramminglanguages. You can reproduce with single click (by clicking green run button at the top of the page). Remember to delete dest
directory before you run the task (if it exists)
Gulp 4 Node 10.12.0 Npm 6.4.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Does glob() have negation? - php - Stack Overflow
A quick way would be to glob() for everything and use preg_grep() to filter out the files that you do not want.
Read more >zsh glob pattern to match all files except one, does not work ...
The glob~filter (and-not) operator applies a filter as a negative pattern matching on the result of the whole glob. That allows things like:...
Read more >How To Script Error Free Bash If Statement? - Shell Tips!
The reason for the Bash error binary operator expected is generally due to a variable being expanded to multiple words and not being...
Read more >Explaining Globs | gulp.js
The first finds a set of matches, then the negative glob removes a portion of those results.
Read more >4. Glob Patterns And Other Basics - Exploring Expect [Book]
As I stated earlier, expect returns with whatever is the longest string that matches the pattern. The problem here is that the remainder...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@plesiecki I would have to do a ton of research to figure out if we could use it. Even then, it might cause unexpected issues which would require a major bump.
However, I did more investigating here and found that I was mistaken with the way ignores work. You need to specify
node_modules/**
and then node-glob removes the/**
part and just matches the base directory. See the code at https://github.com/isaacs/node-glob/blob/master/common.js#L42 - so it wasn’t actually a regression and I just need to update our docs.@phated Awesome. Just noticed fast-glob doesn’t have this issue.
fast-glob
is a drop-in replacement fornode-glob
. I can send a PR.