sindresorhus/gulp-filter

concat restored files does not work

Closed this issue · 11 comments

I've updated to 3.0.0 and tried to change to the new restore API. A basic example works (pipe the restored files to dest) but fails when I pipe to gulp-concat.

gulp.task('test', function () {
  var testFilter = filter(['**', '!**/*-test.js'], { restore: true, passthrough: false });

  var stream = gulp.src('src/**/*.js',)
    .pipe(testFilter)
    .pipe(concat('a.js'))
    .pipe(gulp.dest(path.build + 'test1'));

  testFilter.restore
    .pipe(concat('b.js'))  // <---
    .pipe(gulp.dest(path.build + 'test2'));

  return stream;
});

The filtered files are copied to test2 if I remove the line. With the line, nothing happens in test2.

Can you tell me which version of steamfilter is installed in your setup ? If it is set to 1.0.3, try to install 1.0.2. I'm aware of this bug, something will ship soon.

This update should solve the problem https://github.com/nfroidure/streamfilter/releases/tag/v1.0.4

Reinstalling gulp-filter should solve the issue.

Still doesn't work, with gulp-filter v3.0.1 and streamfilter 1.0.2 to 1.0.5

Not working for me either:

{
    "gulp-concat": "^2.6.0",
    "gulp-filter": "^3.0.1"
}
$ npm install --save gulp-filter
gulp-filter@3.0.1 node_modules\gulp-filter
├── streamfilter@1.0.5 (readable-stream@2.0.4)
└── multimatch@2.0.0 (minimatch@2.0.10)

Would be great to have a complete setup reproducing the issue.

This is the function I'm using:

ops.js.build = function(taskName, src, dest) {
    var foundation = $.filter([
            '**/*',
            paths.bower.foundation.src + 'js/vendor/modernizr.js',
            '!' + paths.bower.foundation.src + '**/*'
        ], {
            restore: true,
            passthrough: false
        }),
        stream;

    stream = gulp.src(src, {base: process.cwd()})
        .pipe($.plumber({errorHandler: ops.showError}))
        .pipe(foundation)
        .pipe($.rename(function (filePath) {
            filePath.dirname = filePath.dirname.replace(path.normalize(paths.assets.src + 'js/'), '');
        }))

        .pipe($.debug({title: taskName}))

        // Start Sourcemapping
        .pipe($.sourcemaps.init())

        // ES6 -> ES5
        .pipe($.babel({
            comments: false
        }).on('error', ops.showError))

        // Write File
        .pipe($.sourcemaps.write('.'))
        .pipe(gulp.dest(dest));

    foundation.restore
        .pipe($.sourcemaps.init())
        .pipe($.concat('foundation.js'))
        .pipe($.sourcemaps.write('.'))

        .pipe($.debug({title: taskName}))
        .pipe(gulp.dest(dest));

    return stream;
};

I expected something like the following: https://github.com/nickdunn/gulp-iconfont-testcase

So you'd like me to make a sample project and upload it for you to test locally as well? I can do that if you'd like.

That would be very helpful. Thanks!

I tweaked it into a simpler package:

bower.json

{
  "name": "GitHub Issue Test",
  "version": "0.0.0",
  "dependencies": {
    "foundation": "5.4.5",
  }
}

gulpfile.js

'use strict';

var $ = {
        concat: require('gulp-concat'),
        debug: require('gulp-debug'),
        filter: require('gulp-filter'),
    },
    buildJs,
    gulp = require('gulp');

buildJs = function(taskName, src, dest) {
    var foundation = $.filter([
            '**/*.js',
            'bower_components/foundation/js/vendor/modernizr.js',
            '!' + 'bower_components/foundation/**/*.js'
        ], {
            restore: true,
            passthrough: false
        }),
        stream;

    stream = gulp.src(src, {base: process.cwd()})
        .pipe(foundation)
        .pipe(gulp.dest(dest));

    foundation.restore
        .pipe($.concat('foundation.js'))
        .pipe(gulp.dest(dest));

    return stream;
};

gulp.task('default', buildJs);