Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added example for cloning repositories recursively
  • Loading branch information
leonardotiberi committed May 16, 2018
commit c83c5a1a75af756414fa2f30f137318e59b4c000
35 changes: 35 additions & 0 deletions examples/clone-recursive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var nodegit = require("../");
var path = "tmp/nodegit-clone-demo";

var config = {
fetchOpts: {
callbacks: {
certificateCheck: function() {
// github will fail cert check on some OSX machines
// this overrides that check
return 1;
}
}
}
};

var entry;

nodegit.Clone("https://github.com/nodegit/nodegit.git", path, config).then(function(repo){
console.log(1);
var p = Promise.resolve();
nodegit.Submodule.foreach(repo, function(submodule){
submodule.update(1, config);
p = p.then(function(){
return new Promise(function(resolve, reject){
submodule.update(1, config).then(resolve, reject);
});
});
}).then(function(){
p.then(function(){
console.log("Cloned!");
},function(error){
console.error(error);
});
});
}).catch(console.log);