Browse Source

callback on correct timing

pull/3405/head
yangjie 9 years ago
parent
commit
35ee9c9b45
1 changed files with 11 additions and 4 deletions
  1. 15
      tasks/build/css.js

15
tasks/build/css.js

@ -21,6 +21,7 @@ var
print = require('gulp-print'), print = require('gulp-print'),
rename = require('gulp-rename'), rename = require('gulp-rename'),
replace = require('gulp-replace'), replace = require('gulp-replace'),
runSequence = require('run-sequence'),
// config // config
config = require('../config/user'), config = require('../config/user'),
@ -47,7 +48,8 @@ module.exports = function(callback) {
var var
stream, stream,
compressedStream, compressedStream,
uncompressedStream
uncompressedStream,
completeCount = 0
; ;
console.info('Building CSS'); console.info('Building CSS');
@ -57,6 +59,12 @@ module.exports = function(callback) {
return; return;
} }
function complete() {
if (++completeCount === 2) {
callback()
}
}
// unified css stream // unified css stream
stream = gulp.src(source.definitions + '/**/' + globs.components + '.less') stream = gulp.src(source.definitions + '/**/' + globs.components + '.less')
.pipe(plumber(settings.plumber.less)) .pipe(plumber(settings.plumber.less))
@ -82,7 +90,7 @@ module.exports = function(callback) {
.pipe(gulp.dest(output.uncompressed)) .pipe(gulp.dest(output.uncompressed))
.pipe(print(log.created)) .pipe(print(log.created))
.on('end', function() { .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(gulp.dest(output.compressed))
.pipe(print(log.created)) .pipe(print(log.created))
.on('end', function() { .on('end', function() {
gulp.start('package compressed css');
callback();
runSequence('package compressed css', complete);
}) })
; ;
Loading…
Cancel
Save