Skip to content

Commit

Permalink
callback on correct timing
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjay committed Nov 30, 2015
1 parent 2e1560f commit 35ee9c9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tasks/build/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -47,7 +48,8 @@ module.exports = function(callback) {
var
stream,
compressedStream,
uncompressedStream
uncompressedStream,
completeCount = 0
;

console.info('Building CSS');
Expand All @@ -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))
Expand All @@ -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);
})
;

Expand All @@ -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);
})
;

Expand Down

0 comments on commit 35ee9c9

Please sign in to comment.