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.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
phatedcommented, 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.

0reactions
calvinjuarezcommented, Nov 30, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Negating a pattern is not working · Issue #3 · sindresorhus/del
UPDATE: Not using nodir . Seems like the negate should follow the path to the folders and remove the parents from the matches...
Read more >
Negating a pattern in gitignore isn't working - Stack Overflow
I tried the commented patterns in a .gitignore file in the directory immediately above the files I want to unignore, but had the...
Read more >
Why can't the extended glob */ be negated with !(*/)?
The shell splits a x/y/z glob on / s. For each component, if the component contains glob operators, the shell lists the parent...
Read more >
gitignore Documentation - Git
Patterns read from a .gitignore file in the same directory as the path, or in any parent directory (up to the top-level of...
Read more >
Oppositional Defiant Disorder (ODD): Symptoms & Treatment
Oppositional defiant disorder (ODD ) is a condition in which your child displays a pattern of uncooperative, defiant and angry behavior ...
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