-
-
Save l00f00/4a267b8a33299f19f2755a82ad0866d0 to your computer and use it in GitHub Desktop.
Download zipped repository from github. If repo is private, you have to use token (create in user profile).
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
const request = require('request'); | |
const fs = require('fs'); | |
const repo = 'miwaniec/socket-camera'; | |
const accessToken = ''; /* for private repo, use token - https://github.com/settings/tokens */ | |
var options = { | |
method: 'GET', | |
url: 'https://api.github.com/repos/' + repo + '/zipball/', | |
encoding: 'binary', | |
headers: { | |
'Authorization': (accessToken != '' ? 'token ' + accessToken : '' ), | |
'User-Agent': 'miwaniec-app' | |
} | |
}; | |
request(options, function(error, response, body) { | |
if (error || response.statusCode !== 200) { | |
console.log('Failed to get repo ', response.statusCode); | |
} else { | |
console.log('We got the repo!'); | |
fs.writeFile('repo.zip', body, 'binary', function (err) {}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment