-
Notifications
You must be signed in to change notification settings - Fork 1
/
jst-nuke-add-owners
executable file
·40 lines (36 loc) · 1.09 KB
/
jst-nuke-add-owners
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
#!/usr/bin/env node
var repos = require('./repos');
var spawnSync = require('child_process').spawnSync;
var expectedOwners = require('./owners.json').owners;
var res = spawnSync('npm', ['whoami']);
if (res.error) throw res.error;
var me = res.stdout.toString().trim();
var ignoredRepos = [
'boilerplate',
'www',
'meta',
'nuke'
];
repos(function (err, data) {
if (err) throw err;
data.forEach(function (repo) {
if (ignoredRepos.indexOf(repo.name) !== -1) return;
var res = spawnSync('npm', ['owner', 'ls', repo.name]);
if (res.error) throw res.error;
var owners = res.stdout.toString().split('\n').map(function (owner) {
return owner.split(' ')[0];
}).filter(Boolean);
console.log(repo.name);
if (owners.indexOf(me) !== -1) {
expectedOwners.forEach(function (owner) {
if (owners.indexOf(owner) === -1) {
console.log(' - adding ' + owner);
var res = spawnSync('npm', ['owner', 'add', owner, repo.name]);
if (res.error) throw res.error;
}
});
} else {
console.log(' - not an owner');
}
});
})