-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
35 lines (29 loc) · 725 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
30
31
32
33
34
35
export default function newGithubReleaseUrl(options = {}) {
let repoUrl;
if (options.repoUrl) {
repoUrl = options.repoUrl;
} else if (options.user && options.repo) {
repoUrl = `https://github.com/${options.user}/${options.repo}`;
} else {
throw new Error('You need to specify either the `repoUrl` option or both the `user` and `repo` options');
}
const url = new URL(`${repoUrl}/releases/new`);
const types = [
'tag',
'target',
'title',
'body',
'isPrerelease',
];
for (let type of types) {
const value = options[type];
if (value === undefined) {
continue;
}
if (type === 'isPrerelease') {
type = 'prerelease';
}
url.searchParams.set(type, value);
}
return url.toString();
}