I am working on project and I want to commit and push on git using by gulp but I am facing some issue when I am running git task so push then task is not waiting for commit....
Anyone can do my help! I want to make the task like first run commit and then push automatically and don't run push task until complete commit task....
Gulp Task for Gulp Git Commit and Push!
var gulp = require('gulp'),
runSequence = require('run-sequence'),
gutil = require('gulp-util'),
git = require('gulp-git'),
prompt = require('gulp-prompt');
/* task to commit and push all file on git
******************************************************************/
// git commit task with gulp prompt
gulp.task('gulp:commit', function(){
// just source anything here - we just wan't to call the prompt for now
gulp.src('./*')
.pipe(prompt.prompt({
type: 'input',
name: 'commit',
message: 'Please enter commit message...'
}, function(res){
// now add all files that should be committed
// but make sure to exclude the .gitignored ones, since gulp-git tries to commit them, too
return gulp.src([ '!node_modules/', './*' ], {buffer:false})
.pipe(git.commit(res.commit));
}));
});
// Run git push, remote is the remote repo, branch is the remote branch to push to
gulp.task('gulp:push', ['gulp:commit'], function(cb){
git.push('origin', 'master', cb, function(err){
if (err) throw err;
});
});
// # task completed notification with green color!
gulp.task('gulp:done', ['gulp:push'], function(){
console.log('');
gutil.log(gutil.colors.green('************** Git push is done! **************'));
console.log('');
});
// gulp task to commit and push data on git
gulp.task('git', function(){
runSequence(['gulp:commit', 'gulp:push', 'gulp:done'])
});