Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negation of patterns including parent directories (../) seems not to work. #306

Closed
calvinjuarez opened this issue Nov 30, 2018 · 8 comments · Fixed by #343
Closed

Negation of patterns including parent directories (../) seems not to work. #306

calvinjuarez opened this issue Nov 30, 2018 · 8 comments · Fixed by #343

Comments

@calvinjuarez
Copy link

calvinjuarez commented Nov 30, 2018

Given:
File structure:

/
├┬ src/
|├ File.js
|├ File.spec.js
│└ FileSpec.js
└┬ build/
 └ gulpfile.js

Glob array:

[
  '../src/**/*.js',
  '!../**/*{s,S}pec.js',
]

What were you expecting to happen?
The ! negation pattern would exclude the spec files from the stream. Given the gulpfile below, I expect to see something like this when I run gulp:

...
[00:00:00] gulp-debug: ../src/deep/File.js
[00:00:00] gulp-debug: 1 item
...

What actually happened?

The negation pattern doesn't seem to apply correctly. Given the gulpfile below, I actually see something like this when I run gulp:

...
[00:00:00] gulp-debug: ../src/deep/File.js
[00:00:00] gulp-debug: ../src/deep/File.spec.js
[00:00:00] gulp-debug: ../src/deep/FileSpec.js
[00:00:00] gulp-debug: 3 items
...

Please post a sample of your gulpfile (preferably reduced to just the bit that's not working)

gulpfile.js

const gulp = require('gulp')
const debug = require('gulp-debug')

const FILES = [
  '../src/**/*.js',
  '!../**/*{s,S}pec.js',

  // or even any of these
  '!../**/*spec.js',
  '!../**/*Spec.js',
  '!../src/**/*{s,S}pec.js',
  '!../src/*{s,S}pec.js',
  // or even the file path specifically
  '!../src/File.spec.js',
  '!../src/FileSpec.js',
]

gulp.task('default', function () {
  return gulp.src(FILES).pipe(debug())
})

What version of gulp are you using?

Gulp 4. (Notably, Gulp 3 works as expected.)

What versions of npm and node are you using?

  • node v11.1.0
  • npm 6.4.1

This is a .zip file of the reduced test case as described above. FWIW, the zip also includes a build-with-gulp-v3/ directory that allows comparing to gulp v3.9.1 behavior.

gulp-negation-issue.zip

@calvinjuarez
Copy link
Author

Update: Apologies, in the ZIP above, build/gulpfile.js lines 14-15 should look like this:

	'!../src/File.spec.js',
	'!../src/FileSpec.js',

(The deep/ was from a time I thought more complex globbing was necessary to replicate the issue.)

@phated
Copy link
Member

phated commented Nov 30, 2018

This has already been reported at gulpjs/gulp#2211

There's a workaround in that thread, as we likely won't have a chance to look into this any time soon.

@calvinjuarez
Copy link
Author

calvinjuarez commented Nov 30, 2018

@phated Thanks! (And for your patience; I searched both here and there, but clearly not well enough. :P)

@calvinjuarez
Copy link
Author

@phated Unfortunately, that workaround would involve a major restructure for our project. If I were to try to look into it myself, do you have any tips for how/where I should get started?

@phated
Copy link
Member

phated commented Nov 30, 2018

Using the cwd option would be a major refactor?

It's likely an issue in node-glob because we rely on it for negation now (we used to do it ourselves but it was massively slower)

@calvinjuarez
Copy link
Author

Whoops! Missed that one for the comment before it! 😳 So sorry. cwd will probably do me just fine, I think. Thanks again!

@phated
Copy link
Member

phated commented Nov 30, 2018

Awesome. Hope it works. I'll keep this open so we have a reference to the issue in this repo. Thanks for opening it.

@phated
Copy link
Member

phated commented Jun 11, 2023

We switched our implementation of to-absolute-glob to a fork that supports this. I'll add a regression test and close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants