2016-03-09 95 views
0

我正在尝试使用nodejs来执行多文件提交。就像你将通过命令行提交和推送git一样。使用Nodejs的Git多文件提交

为了实现这一点,我已经研究了几个节点模块,但不幸的是他们都没有提供多文件提交。这不可能吗?它如何通过命令行工作?

这是一对夫妇的API我已经试过:

+0

如何使用[child_process.exec](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)?你可以运行常规的'git commit -am'bla''。 – lemavri

回答

0

我使用节点GitHub的API,让使提交给托管回购写了一个小模块在github上无需使用Git

https://github.com/Ramshackle-Jamathon/commit-to-github

var commitToGithub = require("commit-to-github"); 
commitToGithub({ 
    user: "Ramshackle-Jamathon", 
    repo: "commit-to-github", 
    token: "<a-github-oauth-token>", 
    files: [ 
     {path: "foo.txt", content: "nice words!"}, 
     {path: "sick-folder/bar.txt", content: "you're the best!"}, 
    ], 
    fullyQualifiedRef : "heads/master", //optional default = "heads/dev" 
    forceUpdate: true, //optional default = false 
    commitMessage: "great work!" //option default = "AutoCommit - " + new Date().getTime().toString(); 
}).then(function(res){ 
    // success! 
}).catch(function(err){ 
    // oh no! something went wrong 
})