sindresorhus / gulp-filter

Filter files in a `vinyl` stream
MIT License
315 stars 37 forks source link

Problem to restore the filtered files #50

Closed brenolf closed 9 years ago

brenolf commented 9 years ago

I'm trying the following:

  return gulp
  .src('./bower.json')
  .pipe(bower())

  .pipe(filters.js)
  .pipe(uglify())
  .pipe(rename({
      suffix: '.min'
  }))
  .pipe(filters.js.restore)
  .pipe(gulp.dest(vendor + '/js/'));

and I get the following error:

TypeError: Cannot read property 'on' of undefined
    at Transform.Readable.pipe (_stream_readable.js:495:7)
    at Gulp.<anonymous> (/Users/breno/Documents/nativo-landing/gulpfile.js:62:4)
    at module.exports (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)

If I try filters.js.restore() instead, then I get the following error:

TypeError: undefined is not a function
    at Gulp.<anonymous> (/Users/breno/Documents/nativo-landing/gulpfile.js:62:20)
    at module.exports (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/Users/breno/Documents/node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3

I'm using an object to handle all my filters:

var filters = {
    js: filter('**/*.js'),
    css: filter('*.css'),
    font: filter(['*.eot', '*.woff', '*.svg', '*.ttf']),
    img: filter(['*.png', '*.gif'])
  };
sindresorhus commented 9 years ago

If you want to use the restore stream you need to explicitly specify so in the options.

There are docs for this. Please read them: https://github.com/sindresorhus/gulp-filter#optionsrestore https://github.com/sindresorhus/gulp-filter#multiple-filters