Change your jekyll
task to include an async callback, like so:
gulp.task('jekyll', ['scripts', 'styles'], function (gulpCallBack) {
var spawn = require('child_process').spawn;
var jekyll = spawn('jekyll', ['build', '--config', 'app/markdown/_config.yml', '--trace'], {stdio: 'inherit'});
jekyll.on('exit', function(code) {
gulpCallBack(code === 0 ? null :'ERROR: Jekyll process exited with code: '+code');
});
});
All that is changed is adding the callback function argument to the task function's signature, and listening to the exit
event on your spawned process to handle the callback.
Now gulp can be notified when the Jekyll process exits. Using the exit code will allow you to capture errors and stop processing.
Note: You might be able to simplify this to, depending on the exit code:
jekyll.on('exit', gulpCallBack);