简体   繁体   中英

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

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));
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM