-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathfetch_package_names.js
More file actions
47 lines (39 loc) · 943 Bytes
/
fetch_package_names.js
File metadata and controls
47 lines (39 loc) · 943 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
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
// ./fetch_package_names <suffix> > output
// ./fetch_package_names "-loader" > output.json
const GitHubApi = require("github");
if (require.main === module) {
main();
} else {
module.exports = fetchPackageNames;
}
function main() {
const suffix = process.argv[2];
if(!suffix) {
return console.error('Missing suffix!');
}
fetchPackageNames({
organization: 'webpack',
suffix: suffix
}, function(err, d) {
if (err) {
return console.error(err);
}
console.log(JSON.stringify(d, null, 4));
});
}
function fetchPackageNames(options, cb) {
const github = new GitHubApi();
// XXX: weak since this handles only one page
github.repos.getForOrg({
org: options.organization,
per_page: 100
}, function (err, d) {
if (err) {
return cb(err);
}
return cb(null, d.filter(function(o) {
return o.name.endsWith(options.suffix);
}));
});
}