Skip to content

Instantly share code, notes, and snippets.

@LasaleFamine
Created May 21, 2018 14:20
Show Gist options
  • Select an option

  • Save LasaleFamine/237f29daf5553214a5b77a2f4c4a0b33 to your computer and use it in GitHub Desktop.

Select an option

Save LasaleFamine/237f29daf5553214a5b77a2f4c4a0b33 to your computer and use it in GitHub Desktop.
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