gulp task starts but does not end

怎甘沉沦 提交于 2019-12-12 06:16:35

问题


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;
  });

I can not understand two things: 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 5.72 s"

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?

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 What is wrong?

来源:https://stackoverflow.com/questions/30237838/gulp-task-starts-but-does-not-end

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!