loewydesign / loewy-assets

A front-end asset pipeline driven by gulp.js.
MIT License
12 stars 3 forks source link

JS task does not call done callback, so Gulp doesn't know when it's done #3

Closed agopshi closed 9 years ago

agopshi commented 9 years ago
gulp.task('js', ['clean-js'], function(done) {
    for (var i = 0; i < taskFuncs.length; ++i)
    {
        var taskFunc = taskFuncs[i];
        taskFunc();
    }
});

The done callback is never called. Even through the task will usually complete successfully, Gulp will not know about its completion.

agopshi commented 9 years ago

It looks like streams have an end event. We should be able to do something like this:

gulp.task('js', ['clean-js'], function(done) {
    var taskFuncsLeft = taskFuncs.length;
    for (var i = 0; i < taskFuncs.length; ++i)
    {
        var taskFunc = taskFuncs[i];
        taskFunc().on('end', function() {
            if (--taskFuncsLeft <= 0)
            {
                done();
            }
        });
    }
});

That should call the done() callback when all of the task funcs finish.

agopshi commented 9 years ago

Fixed in v0.1.0.