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

watch doesn't have same negation as src/dest (v4.0) #2192

Closed
shnam7 opened this issue Jun 21, 2018 · 12 comments
Closed

watch doesn't have same negation as src/dest (v4.0) #2192

shnam7 opened this issue Jun 21, 2018 · 12 comments
Labels
Bug Bounty: $200 Fix this issue to claim the $200 bounty. bug gulp4 help wanted upstream Issues that need to be fixed upstream

Comments

@shnam7
Copy link

shnam7 commented Jun 21, 2018

What were you expecting to happen?
gulp.watch() glob should work with exclude expression (ex: !docs/gulpfile.js)

What actually happened?
qulp.watch() is triggered even with the exclude expression.

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

const watched = ['docs/**/*', '!docs/gulpfile.js' ];

gulp.src(watched).pipe(require('gulp-debug')());

gulp.watch(watched, (done)=>{
  console.log('watch triggered'); done();
});

In this example, gulp.src() shows correct file list which is not including 'docs/gulpfile.js', but gulp.watch() triggers when I make changes on 'docs/gulpfile.js'

What version of gulp are you using?
gulp 4.0.0

What versions of npm and node are you using?
node 10.4.1

@phated
Copy link
Member

phated commented Jun 21, 2018

Hey @shnam7 - I don't actually know if chokidar (the watching library we use) implements our negation logic (it's custom). I'm guessing they'd be willing to accept the custom logic? /cc @es128

@es128
Copy link
Contributor

es128 commented Jun 21, 2018

Try setting the negated glob(s) first in the array

@phated
Copy link
Member

phated commented Jun 21, 2018

That might solve this small example but it's still not the same as our negation logic (which happens in sequential order). Would you be willing to accept changes to that?

@es128
Copy link
Contributor

es128 commented Jun 21, 2018

I’m not sure whether my suggestion will solve this case, but anyway yes I would accept contributions to improve it.

@shnam7
Copy link
Author

shnam7 commented Jun 22, 2018

Hi,
I tried with negation logic first in the array, but the result is the same.

const watched = ['!docs/gulpfile.js', 'docs/**/*' ];

In that case, I see that gulp.src() also shows that the 'docs/gulpfile.js' is not excluded, possibly this is the normal logic of gulp. Is it correct?

@phated phated added bug help wanted upstream Issues that need to be fixed upstream labels Jun 22, 2018
@shnam7
Copy link
Author

shnam7 commented Jun 22, 2018

Let me share a couple of things that I found in my testing with gulp.watch() glob patterns.

Test pattern: '!docs/{aa,_bb}'

gulp.watch() does not triggers on 'aa', 'bb', 'aa/**/*', 'bb/**/*' --> vs. expecting only 'aa' and 'bb' to be excluded

Test pattern: 'docs/data'

gulp.watch triggers on changes of file 'data' (including create and delete), but does not triggers on directory 'data' (create, delete).
In addition, when directory 'data' is deleted, gulp.watch() task crashes with error message below:

gulp --color --gulpfile D:\myproject\gulpfile.js @watch[246832]: src\fs_event_wrap.cc:91: Assertion `(wrap) != nullptr' failed.
 1: node::DecodeWrite
 2: node::DecodeWrite
 3: node::Start
 4: v8::internal::FeedbackVector::New
 5: v8::internal::FeedbackVector::New
 6: v8::internal::FeedbackVector::New
 7: v8::internal::Object::ToInt32
 8: v8::internal::Object::GetProperty
 9: v8::internal::FeedbackVector::New
10: v8::internal::FeedbackVector::New
11: 000000389E2841C1

@phated
Copy link
Member

phated commented Jun 22, 2018

@shnam7 basically everything you are pointing out is related to chokidar - please open issues for them at https://github.com/paulmillr/chokidar

I've labelled this issue with upstream because your issues might already be documented on their issue tracker. I've labelled it help wanted because none of the gulp team has direct access to that repo so we're in the same boat as you and none of us have much time to try to upstream your fixes.

@shnam7
Copy link
Author

shnam7 commented Jun 22, 2018

OK, thanks. That's good!!

@phated phated changed the title gulp.watch exclude does not work (gulp 4.0.0) watch doesn't have same negation as src/dest (v4.0) Jul 29, 2018
@phated phated added the gulp4 label Jul 29, 2018
@phated phated added the Bug Bounty: $200 Fix this issue to claim the $200 bounty. label Nov 14, 2018
@phated
Copy link
Member

phated commented Nov 14, 2018

We've just added a Bug Bounty of $200 on this issue if anyone wants to solve it.

@phated
Copy link
Member

phated commented Nov 16, 2018

Our first bug bounty has been claimed 🎉🙌 That was super quick!

This was released as a patch release in glob-watcher. Update your dependencies (remember to deal with any package-locks) to get the fix.

@James-Quigley
Copy link

@ghost

This comment has been minimized.

@gulpjs gulpjs locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Bounty: $200 Fix this issue to claim the $200 bounty. bug gulp4 help wanted upstream Issues that need to be fixed upstream
Projects
None yet
Development

No branches or pull requests

4 participants