sindresorhus / gulp-filter

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

Restore does not save order of files #72

Closed denieler closed 8 years ago

denieler commented 8 years ago

Hi!

We've had a bug with modules order because of the issue in your restore function. It is not saving the order of files that was in gulp.src before.

Example:

return gulp.src(["file1.js", "file2.coffee", "file3.js"])
           .pipe(filterCoffee)
           .pipe(compileCoffeeFiles())
           .pipe(filterCoffee.restore)
           .pipe(concat(fileName))
           .pipe(gulp.dest(fileDir));

In this example, on some CPUs you'll have order file1, file3, file2 in the result.

But concat save order from gulp.src

nfroidure commented 8 years ago

Order will be preserved only if you use streams, this is a known issue with gulp and buffers https://github.com/gulpjs/gulp/issues/300

denieler commented 8 years ago

@nfroidure wait, for concat it works, why it doesn't work for restore function for your plugin?

nfroidure commented 8 years ago

concat concats files as they come, gulp filter split them and feed 2 different streams which leads to concurrence issues i pointed out on gulp.

nfroidure commented 8 years ago

To be honest, i find it bad too, it should be fixed on Gulp itself. I gave a path on the Gulp issue to avoid it.

denieler commented 8 years ago

I had to use

.....
.pipe(gulpIf(fileCoffee, compileCoffee()))
.pipe(....

instead of your package because of this bug. Can you please add this to documentation of restore function? Because it is not clear. Thanks!

nfroidure commented 8 years ago

@denieler feel free to, i do not use Gulp anymore ;)