2016-03-09 87 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 
})