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
This is same as last example from https://gulpjs.com/docs/en/getting-started/explaining-globs#special-character-negative :thinking:
Can you try this:
const {src, dest} = require('gulp');
module.exports.default = () => src(['**/*.html', '!**/bar/**']).pipe(dest('dest'));
I just ran the repl.it in the original link and the output is correct. There is no bar in the dest/ directory.

@phated The original link contain edited code!
This still not working: module.exports.default = () => src(['**/*.html', '!bar/']).pipe(dest('dest'));
This work : module.exports.default = () => src(['**/*.html', '!**/bar/**']).pipe(dest('dest'));


But when it's working for OP then this can stay closed.
@phated Sorry, repl.it example was modified with @nstungcom idea:
Can you try this:
const {src, dest} = require('gulp'); module.exports.default = () => src(['**/*.html', '!**/bar/**']).pipe(dest('dest'));
I restored original code.
@nstungcom What does OP stand for?
@plesiecki this seems to be an issue with node-glob
I just ran this test:
const glob = require('glob');
console.log(glob.sync('**/*.html', { ignore: 'bar/' }))
and the results are the same as what you are seeing with gulp (we use node-glob as a dependency)
You can also use:
src(['**/*.html', '!bar/**/*']).pipe(dest('dest'));
as an alternative, but I'd recommend scoping your original glob better because it picks up dest on subsequent runs.
I'll create a followup issue to fix the docs.
@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.
@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.
Awesome, great work :heart: