Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to customize git commit message in gulp.js task runner

I have implemented gulp.js into my current project build and I'm using gulp-git. I'm trying to figure out if there is a way I can allow the user the option of entering a unique commit message after typing the 'gulp commit' command in the terminal. Is this possible?

Here is the current gulp task.

gulp.task('commit', function(){
  gulp.src('./*', {buffer:false})
  .pipe(git.commit('initial commit'));
});

I am using the gulp-git package https://github.com/stevelacy/gulp-git

like image 789
lollipopwizardkid Avatar asked May 11 '26 10:05

lollipopwizardkid


1 Answers

Have a look at gulp-prompt which appears to be what your looking for:

https://www.npmjs.com/package/gulp-prompt

I haven't tested this, but something like this should work:

Install gulp-prompt npm install gulp-prompt

Then edit your gulp task.

gulp.task('commit', function(){
    var message;
    gulp.src('./*', {buffer:false})
    .pipe(prompt.prompt({
        type: 'input',
        name: 'commit',
        message: 'Please enter commit message...'
    }, function(res){
        message = res.commit;
    }))
    .pipe(git.commit(message));
});
like image 71
rjmacarthy Avatar answered May 13 '26 23:05

rjmacarthy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!