-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcontributors.js
More file actions
35 lines (28 loc) · 903 Bytes
/
Copy pathcontributors.js
File metadata and controls
35 lines (28 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const request = require('request')
const path = require('path')
const fs = require('fs')
const dest = path.join(__dirname, '..', 'build', 'contributors.json')
contributors(function (err, list) {
if (err) throw err
fs.writeFileSync(dest, JSON.stringify(list))
})
function contributors (done) {
request('http://stack.gl/packages/index.json', {
json: true
}, function (err, res, body) {
if (err) return done(err)
const repos = Object.keys(body.repos).reduce(function (repos, category) {
return repos.concat(body.repos[category])
}, [])
const contributors = body.contributors
repos.forEach(function (repo) {
repo.contrib.forEach(function (idx) {
contributors[idx].count = contributors[idx].count || 0
contributors[idx].count++
})
})
done(null, contributors.sort(function (a, b) {
return b.count - a.count
}))
})
}