Created
May 21, 2018 14:20
-
-
Save LasaleFamine/237f29daf5553214a5b77a2f4c4a0b33 to your computer and use it in GitHub Desktop.
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 fs = require('fs'); | |
| const vsts = require('vso-node-api'); | |
| const repoId = 'YOUR_REPO_ID'; | |
| const token = 'YOUR_TOKEN'; | |
| const run = async () => { | |
| const writeStream = fs.createWriteStream('./output.zip'); | |
| const authHandler = vsts.getPersonalAccessTokenHandler(token); | |
| const handler = new vsts.WebApi('https://<username>.visualstudio.com/defaultcollection', authHandler); | |
| const gitApi = await handler.getGitApi(); | |
| const repoStream = await gitApi.getItemZip(repoId); | |
| repoStream.pipe(writeStream); | |
| repoStream.on('end', () => console.log('ENDED')); | |
| writeStream.on('error', err => { | |
| console.log(err); | |
| }); | |
| }; | |
| run().catch(err => console.error(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment