Search code examples
javascriptnode.jspluginsgulpgulp-filter

Gulp plugin "gulp-filter" not restoring files in the stream as intended


I have a gulp task that does a pretty simple task, it searches for all files in a folder, filter html files, validate them and then restore file stream and push every file type in the destination folder. This gulpfile:

// define gulp
var gulp = require('gulp');

// define plug-ins
var filter = require('gulp-filter');
var w3cjs = require('gulp-w3cjs');
var newer = require('gulp-newer');

// define paths
var src_path = 'src';
var dest_path =  'public';

// Copy all files from /src, validate html files, and and push everything inside /public

gulp.task('files', function() {
    return gulp.src(src_path + '/*')  //search for all files
    .pipe(newer(dest_path))  // if new go on, if old skip
    .pipe(filter('*.html'))  // filter html files
    .pipe(w3cjs())  // validate filtered files
    .pipe(filter('*.html').restore())  // restore files in pre-filter state
    .pipe(gulp.dest(dest_path))  // push in destination folder
});

It seems that the "restore" is not restoring files, infact only html files are being pushed in production (/public) folder, what could be wrong? Thanks for any help.


Solution

  • maybe assign a variable to var filter = filter('*.html') and use it to restore .pipe(filter.restore()).