akoenig / gulp-svg2png

A gulp plugin for converting SVGs to PNGs.
MIT License
54 stars 34 forks source link

Plugin exits incorrectly when used inside of a multipipe (map-stream issue) #36

Open ashmind opened 7 years ago

ashmind commented 7 years ago

If I use this plugin inside of a multipipe, than the stream never ends, and even though gulp exits, the processing is interrupted and some of the further pipe steps are not processed.

Simplified example (I know pipe here is pointless, real code is more complex):

const gulp = require('gulp');
const g = require('gulp-load-plugins')();
const pipe = require('multipipe');

gulp.task('favicons', function() {
    return gulp
        .src('./favicon*.svg')
        .pipe(pipe(g.svg2png({ width: 16, height: 16 })))
        .pipe(gulp.dest('wwwroot/favicons'));
});

When I run gulp favicons, I get:

> gulp favicons
[12:35:59] Using gulpfile xyz/gulpfile.js
[12:35:59] Starting 'favicons'...

and even though gulp does exit, there is no "Finished" log, and only one file is processed.

I've actually narrowed it down to an issue in map-stream which I reported as dominictarr/map-stream#21, but I thought it would be useful to file here as well.

dominictarr commented 7 years ago

why is it .pipe(pipe(...))?

    .pipe(pipe(g.svg2png({ width: 16, height: 16 })))

does it work as expected if you remove that? can you confirm that map-stream is getting to the end? (should emit and "end" event)

ashmind commented 7 years ago

@dominictarr

does it work as expected if you remove that?

Yes, but the problem is I want multipipe for my scenario.

I don't really remember the details of this one anymore, but here is the test I did for gulp-svg2png: https://github.com/ashmind/gulp-svg2png/commit/e413827d9400cfda9f44ecaa15f915aeabfe35e0#diff-c48ef94ea42b842eba31916c3fd618c3R63

It does not pass with current map-stream, but did pass with my modified version.