teambition / merge2

Merge multiple streams into one stream in sequence or parallel (~119M/month downloads).
MIT License
170 stars 14 forks source link

gulp task starts but does not end #4

Closed pavel06081991 closed 9 years ago

pavel06081991 commented 9 years ago

I have the next files structure:

src/
    themes/
        default/
            1.png
            2.png
        oneMoreTheme/
            3.png
            4.png
dist
    themes/
        default/
        oneMoreTheme/

and the next gulpfile:

  'use strict';

  var gulp = require('gulp'),
    _ = require('lodash'),
    plugins = require('gulp-load-plugins')();

  gulp.task('images', function () {
    var streams = {},
      themes = [
        'default',
        'oneMoreTheme'
      ];

    streams.themesImages = [];

    _.forEach(themes, function(theme) {
      streams.themesImages.push(gulp.src('src/themes/' + theme + '/*.*')
      .pipe(gulp.dest('dist/themes/' + theme + '/')));
    });

    streams.allThemeImages = plugins.merge(streams.themesImages);

    return streams.allThemeImages;
  });

When I use gulp-merge plugin I have two problems I can not understand: 1) Why do I see in console the next text when task "images" starts:

"D:\home\projects\storyBook>gulp images
[15:05:23] Using gulpfile D:\home\projects\storyBook\gulpfile.js
[15:05:23] Starting 'images'..."

But when task is finished I do NOT see the next text:

"[12:13:56] Finished 'images' after 72 ms"

Why do not I get this text? I do streams merge and then return merged stream to have synchronous task. Maybe I do something wrong? Only sometimes I get this message.

2) If I add one code line to my privous code:

streams.allThemeImages = plugins.merge(streams.themesImages);
return streams.allThemeImages.pipe(gulp.dest('temp/')); // HERE IS NEW CODE LINE

I expect that in temp folder I'll have the next images:

temp/ 
    1.png 
    2.png 
    3.png 
    4.png 

Because I merged streams, first one contains 1.png and 2.png images and second one contains 3.png and 4.png. But in reality I get the next files:

temp/ 
    1.png 
    2.png 

Sometimes I get only 1.png inside temp folder and sometimes all work well and I get all images inside temp folder.
What is wrong?

When I use merge2 plugin insted of gulp-merge, all works well and I have not these two problems! Why?

zensh commented 9 years ago

Sorry, the gulp-merge is out of date. I should remove it from npm.