gulp-git:使用push会导致流错误

时间:2016-02-10 18:58:53

标签: javascript node.js git gulp

我尝试使用npm中的gulp-git模块推送到我的远程存储库。添加& commit部分运行正常,但在尝试执行远程推送时会遇到流错误。

bump: function () {
  var branch = argv.branch || 'development';
  fs.readFile('./package.json', function (err, data) {
    if (err) { return ; }
    return gulp.src(['./package.json', './bower.json'])
      .pipe(git.add())
      .pipe(git.commit('chore(core): bump to ' + JSON.parse(data).version))
      .pipe(git.push('origin', branch, function(err) {
        if(err) throw (err);
      }));
  });
}

堆栈跟踪:

  

C:\ SRC \ GIT中\ IG \ node_modules \吞掉-git的\ node_modules \ through2 \ node_modules \可读流\ lib_stream_readable.js:623

     

var written = dest.write(chunk);

                ^
     

TypeError:undefined不是函数       at write(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_readable.js:623:24)       at flow(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_readable.js:632:7)       在DestroyableTransform.pipeOnReadable(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_readable.js:664:5)       在DestroyableTransform.emit(events.js:104:17)       在emitReadable_(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_readable.js:448:10)       在emitReadable(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_readable.js:444:5)       在readableAddChunk(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_readable.js:187:9)       在DestroyableTransform.Readable.push(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_readable.js:149:10)       在DestroyableTransform.Transform.push(C:\ src \ git \ ig \ node_modules \ gulp-git \ node_modules \ through2 \ node_modules \ readable-stream \ lib_stream_transform.js:145:32)       在Array.forEach(native)

我正在运行gulp-git 1.6.0版。它看起来像是1.7.0。也许升级路径会有所帮助,但这似乎是命令的标准用法,所以我认为这是我做错的事。

1 个答案:

答案 0 :(得分:4)

stevelacy(项目管理员)的帮助下,我能够使用此代码更改:

.pipe(git.commit('chore(core): bump to ' + JSON.parse(data).version))
.on('end', function() {
  git.push('origin', branch, function(err) {
    if(err) throw (err);
  });

});

事实证明,git push命令无法从流中完成。