简体   繁体   English

有没有办法在gulp.js任务运行器中自定义git commit消息

[英]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. 我已经将gulp.js实现到我当前的项目构建中,并且我正在使用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. 我试图弄清楚是否有一种方法可以让用户在终端中输入'gulp commit'命令后输入一个唯一的提交消息。 Is this possible? 这可能吗?

Here is the current gulp task. 这是当前的gulp任务。

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 我正在使用gulp-git包https://github.com/stevelacy/gulp-git

Have a look at gulp-prompt which appears to be what your looking for: 看看gulp-prompt看起来像你在寻找:

https://www.npmjs.com/package/gulp-prompt 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 安装gulp-prompt npm install gulp-prompt

Then edit your gulp task. 然后编辑你的gulp任务。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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