diff --git a/examples/clone-recursive.js b/examples/clone-recursive.js new file mode 100644 index 000000000..260fc2f67 --- /dev/null +++ b/examples/clone-recursive.js @@ -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; + } + } + } +}; + +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); \ No newline at end of file