-
Notifications
You must be signed in to change notification settings - Fork 2
/
repos.js
41 lines (25 loc) · 1018 Bytes
/
repos.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
exports.genRepos = (gh, githubUser, config) => {
const allCalls = [];
Object.keys(config).forEach(repoName => {
console.log(`** création dépôts : ${repoName}-front et ${repoName}-back`);
const orga = gh.getOrganization(githubUser);
allCalls.push(orga.createRepo({ name:`${repoName}-front`}));
allCalls.push(orga.createRepo({ name:`${repoName}-back`}));
});
return Promise.all(allCalls);
};
exports.deleteRepos = (gh, githubUser, config) => {
const allCalls = [];
const orga = gh.getOrganization(githubUser);
orga.getRepos()
.then(response => {
return response.data.filter(r => Object.keys(config).some(c => r.name.includes(c)));
})
.then(reposToDelete => {
reposToDelete.forEach(r => {
console.log('** Suppression du dépôt', r.name)
allCalls.push(gh.getRepo(githubUser, r.name).deleteRepo());
})
});
return Promise.all(allCalls);
};