Created
September 1, 2019 18:31
-
-
Save miwaniec/26973ca30646b6511a2f26300e2eb71a 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