Reputation: 6080
I am using gulp run-sequence
and one of my tasks includes a custom remote call to a webservice and I don't want gulp to move on until it's complete, however it immediately moves on because I don't have the proper return.
gulp.task('upload', function() {
fs.readFile('./dist.zip', { encoding: 'base64' }, function(err, data) {
params['ZipFile'] = data;
lambda.updateFunctionCode(params, function(err, data) {
return true;
});
});
});
// Our default task will build a production copy, then upload to Lambda
gulp.task('default', function(callback) {
return runSequence(
['clean'], ['js', 'npm', 'env'], ['zip'], ['upload'],
callback
);
});
Upvotes: 0
Views: 800
Reputation: 3794
You need to use the callback in the 'upload' task so you can signal when that task is done. Like this:
gulp.task('upload', function(callback) {
fs.readFile('./dist.zip', { encoding: 'base64' }, function(err, data) {
params['ZipFile'] = data;
lambda.updateFunctionCode(params, function(err, data) {
callback();
});
});
});
Also do't forget to check for errors on the above fs.readFile and lambda.updateFunctionCode: if(err)...
Upvotes: 2