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

1.5k views Asked by At

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.

1

There are 1 answers

1
eguneys On BEST ANSWER

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