question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Negative glob not working as expected

See original GitHub issue

Hello,

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:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
phatedcommented, Apr 27, 2019

@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.

1reaction
plesieckicommented, Mar 14, 2019

@phated Awesome. Just noticed fast-glob doesn’t have this issue. fast-glob is a drop-in replacement for node-glob. I can send a PR.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found