From 35ee9c9b45bf9176f0d024a42fba867a686af0d2 Mon Sep 17 00:00:00 2001 From: yangjie Date: Mon, 30 Nov 2015 15:15:44 +0800 Subject: [PATCH] callback on correct timing --- tasks/build/css.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tasks/build/css.js b/tasks/build/css.js index 137d11724..75f43a6e5 100644 --- a/tasks/build/css.js +++ b/tasks/build/css.js @@ -21,6 +21,7 @@ var print = require('gulp-print'), rename = require('gulp-rename'), replace = require('gulp-replace'), + runSequence = require('run-sequence'), // config config = require('../config/user'), @@ -47,7 +48,8 @@ module.exports = function(callback) { var stream, compressedStream, - uncompressedStream + uncompressedStream, + completeCount = 0 ; console.info('Building CSS'); @@ -57,6 +59,12 @@ module.exports = function(callback) { return; } + function complete() { + if (++completeCount === 2) { + callback() + } + } + // unified css stream stream = gulp.src(source.definitions + '/**/' + globs.components + '.less') .pipe(plumber(settings.plumber.less)) @@ -82,7 +90,7 @@ module.exports = function(callback) { .pipe(gulp.dest(output.uncompressed)) .pipe(print(log.created)) .on('end', function() { - gulp.start('package uncompressed css'); + runSequence('package uncompressed css', complete); }) ; @@ -97,8 +105,7 @@ module.exports = function(callback) { .pipe(gulp.dest(output.compressed)) .pipe(print(log.created)) .on('end', function() { - gulp.start('package compressed css'); - callback(); + runSequence('package compressed css', complete); }) ;