Advertisement
Guest User

Untitled

a guest
May 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const bitbucket = require('bitbucket-api')
  2.  
  3. const bbClient = bitbucket.createClient({
  4.   username: 'username',
  5.   password: 'hui'
  6. })
  7.  
  8. function collectRecentRepos() {
  9.   return new Promise((resolve, reject) => {
  10.     bbClient.repositories((err, repos) =>
  11.       resolve(repos
  12.           .map(repo => ({ name: repo.slug, updated_at: new Date(repo.utc_last_updated) }))
  13.           .filter(repo => repo.updated_at > (Date.now() - 7 * 24 * 60 * 60 * 1000))
  14.           .sort((a, b) => a.updated_at - b.updated_at))
  15.   })
  16. }
  17.  
  18. function listRecentRepos() {
  19.   collectRecentRepos()
  20.     .then(repos => console.log(repos))
  21. }
  22.  
  23. listRecentRepos()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement