Last active
September 26, 2017 22:36
-
-
Save CaptainYarb/dda3144c525be6c5d560cb4bcb3f8307 to your computer and use it in GitHub Desktop.
Pull github repo in Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nodegit = require('nodegit'); | |
var opts = { | |
fetchOpts: { | |
callbacks: { | |
credentials: function() { | |
return nodegit.Cred.sshKeyNew('git', './ssh/id_rsa.pub', './ssh/id_rsa', ''); | |
}, | |
certificateCheck: function() { | |
return 1; | |
} | |
} | |
} | |
}; | |
nodegit.Clone('[email protected]:nodecraft/stackfiles.git', './stackfiles', opts).then(function(repo){ | |
if(!(repo instanceof nodegit.Repository)){ | |
throw new Error('Failed to pull'); | |
} | |
return repo.getHeadCommit() | |
}).then(function(commit){ | |
console.error('GREAT SUCCESS'); | |
console.dir(commit.toString()); | |
}).catch(function(err){ | |
console.error('ERROR', err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment