1

I can't get the ignore option of gulp.src working:

'use strict';

var gulp = require('gulp');
var debug = require('gulp-debug');

var config = {
  src: 'app/**/*.js',
  test: 'app/**/*.test.js'
}

gulp.task('default', function() {
  return gulp.
    src(config.src, {ignore: config.test}).
    pipe(debug({title: 'debug'}));
});

Output:

[01:33:38] Using gulpfile ~/Projects/gulp-src/gulpfile.js
[01:33:38] Starting 'default'...
[01:33:38] debug app/src.js
[01:33:38] debug app/src.test.js
[01:33:38] debug 2 items
[01:33:38] Finished 'default' after 19 ms

According to gulp api documentation, the option object is passed to node-glob, which has documented ignore option so why my code does not work as expected? Am I misunderstanding something? I would really like to use ignore option in favour of "!whatever/**" pattern.

  • possible duplicate of [Excluding files/directories from Gulp task](http://stackoverflow.com/questions/23384239/excluding-files-directories-from-gulp-task) – DavidDomain Jul 30 '15 at 15:33
  • Unlike "Excluding files...", this question is specific to excluding files using the `ignore` option. – Edward Brey Sep 30 '15 at 14:40
  • Can you check the version of your `glob` dependency? It's probably in `node_modules/gulp/node_modules/vinyl-fs/node_modules/glob-stream/node_modules/glob`. – JMM Sep 30 '15 at 15:52

1 Answers1

0

gulp does not pass through the ignore option (it ignores ignore :-). Instead, gulp has its own negation (!) implementation, which you should use instead.

This behavior was undocumented. I submitted a pull request with corrected documentation.

Edward Brey
  • 40,302
  • 20
  • 199
  • 253