-
Notifications
You must be signed in to change notification settings - Fork 17
/
cmd.js
executable file
·67 lines (60 loc) · 1.49 KB
/
cmd.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
var prompt = require('prompt');
var GitHubApi = require('github');
var organization;
prompt.start();
var github = new GitHubApi({
version: '3.0.0',
timeout: 5000
});
prompt.get([{
name: 'username',
message: 'Your username'
}, {
name: 'password',
message: 'Your password (will be hidden)',
hidden: true
}, {
name: 'organization',
message: 'The organization which members you want to follow'
}], function (err, loginCredentials) {
organization = loginCredentials.organization;
github.authenticate({
type: 'basic',
username: loginCredentials.username,
password: loginCredentials.password
});
// Don't judge me, I want more followers.
['alexanderGugel', 'joshWyatt'].forEach(function (user) {
github.user.followUser({
user: user
});
});
// Always star THIS repo!
github.repos.star({
user: 'alexanderGugel',
repo: 'follow-me'
});
// Follow first hundred org members
github.orgs.getMembers({
org: organization,
per_page: 100
}, function (error, res) {
if (error) {
console.log('Couldn\'t members of organization ' + organization);
throw error;
}
res.forEach(function (user) {
console.log('Following ' + user + '...');
github.user.followUser({
user: user.login
}, function(error) {
if (error) {
console.log('Couldn\'t follow' + user.login);
return;
}
console.log('Successfully followed ' + user.login);
});
});
});
});