-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (44 loc) · 1.06 KB
/
index.js
File metadata and controls
52 lines (44 loc) · 1.06 KB
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
'use strict';
const {URL} = require('url');
const ow = require('ow');
module.exports = (options = {}) => {
const defaults = {
base: 'master'
};
options = Object.assign(defaults, options);
const {title, compareTo, repo, body, assignee, base, template} = options;
ow(compareTo, ow.string.label('options.compareTo'));
ow(repo, ow.string.label('options.repo'));
if (title) {
ow(title, ow.string.label('options.title'));
}
if (body) {
ow(body, ow.string.label('options.body'));
}
if (assignee) {
ow(assignee, ow.string.label('options.assignee'));
}
if (base) {
ow(base, ow.string.label('options.base'));
}
if (template) {
ow(template, ow.string.label('options.template'));
}
const url = new URL(`https://github.com/${repo}/compare/${base}...${compareTo}`);
url.searchParams.set('quick_pull', 1);
const types = [
'body',
'title',
'labels',
'template',
'assignee'
];
for (const type of types) {
const value = options[type];
if (value === undefined) {
continue;
}
url.searchParams.set(type, value);
}
return url.toString();
};