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

gulp.watch glob array is order-dependant #1952

Closed
jackwilsdon opened this issue May 10, 2017 · 1 comment
Closed

gulp.watch glob array is order-dependant #1952

jackwilsdon opened this issue May 10, 2017 · 1 comment

Comments

@jackwilsdon
Copy link

This tracker is for bug reports only.

Before opening an issue, please make sure you've checked the following:

  • For support requests, please use Stack Overflow (stackoverflow.com) or Gitter (see the README).

  • If the bug is in a plugin, open an issue on the plugin repository, not the gulp repository.

  • If you're getting a deprecated module warning, don't worry about it: we're aware of it and it's not an issue. To make it go away, update to Gulp 4.0.

  • If you're asking about the status of Gulp 4, please don't! You can see the remaining issues on the gulp4 label: https://github.com/gulpjs/gulp/issues?q=is%3Aissue+is%3Aopen+label%3Agulp4


What were you expecting to happen?

gulp.watch negations should happen last, similarly to how gulp.src and gulp.dest work.

What actually happened?

Negations happen in the order specified; [ '!src/**/*.js', 'src/**/*' ] ends up not ignoring src/script.js as src/**/* overrode it.

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

gulp.task('default', function() {
  gulp.watch([ '!src/**/*.js', 'src/**/*' ], function(event) {
    console.log('negation first', event);
  });

  gulp.watch([ 'src/**/*', '!src/**/*.js' ], function(event) {
    console.log('negation last', event);
  });
});

You'll need to create at least 1 file in src for the watch to work, due to shama/gaze#177.

Modifying (i.e. adding, removing, etc) any file with a .js extension inside src logs negation first when it should log nothing at all.

It looks like this is a known "feature" of gaze, which is a bit of a pain. The easiest fix would probably be to just sort the glob array like this:

globs.sort((first, second) => first.startsWith('!'))

What version of gulp are you using?

CLI version 3.9.1
Local version 3.9.1

What versions of npm and node are you using?

npm 3.10.10
node v6.10.3
@jackwilsdon jackwilsdon changed the title gulp.watch glob negations are order-dependant gulp.watch glob array is order-dependant May 10, 2017
@phated
Copy link
Member

phated commented May 10, 2017

We proxy directly to the watch libraries and don't plan to add functionality like this to the intermediate library. Please open with chokidar (as we have removed gaze in the next version).

@phated phated closed this as completed May 10, 2017
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

No branches or pull requests

2 participants