-
-
Save mikesprague/6e1fef992c14b38f5d93d069c7d29b1c to your computer and use it in GitHub Desktop.
This file contains 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
// $ yarn add request request-promise | |
// $ node count userA userB | |
const request = require('request-promise') | |
const get = resource => request({ | |
url: /^https/.test(resource) ? resource : `https://api.github.com/${resource}`, | |
headers: { | |
'User-Agent': 'GitHub Contrib Counter', | |
'Authorization': 'token YOUR_PERSONAL_ACCESS_TOKEN' | |
}, | |
json: true | |
}).catch(e => { | |
console.error(e.message) | |
}) | |
const flatten = arr => [].concat.apply([], arr) | |
const count = async () => { | |
const orgs = process.argv.slice(2) | |
const repos = await Promise.all(orgs.map(o => get(`users/${o}/repos`))) | |
const contribs = await Promise.all(flatten(repos).map(r => get(r.contributors_url))) | |
console.log(new Set(flatten(contribs).map(u => u.login)).size) | |
} | |
count() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment