-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
29 lines (23 loc) · 821 Bytes
/
index.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
const { forkOne: forkOneAction, forkMultiple: forkMultipleAction } = require('./src/actions/fork');
async function forkOne(repositoryTarget, options) {
if (!repositoryTarget.owner) {
throw new Error('Missing repository owner');
}
if (!repositoryTarget.repositoryName) {
throw new Error('Missing repository name');
}
await forkOneAction(repositoryTarget, options);
}
async function forkMultiple(repositories = []) {
if (repositories.length === 0) {
throw new Error('Missing repositories');
}
if (repositories.length === 1) {
await forkOneAction(repositories[0]);
return;
}
const validRepositories = repositories
.filter((repository) => (!repository.author && !repository.name));
await forkMultipleAction(validRepositories);
}
module.exports = { forkOne, forkMultiple };