-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathindex.js
53 lines (45 loc) · 1.86 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const verifyGitHub = require('./lib/verify');
const publishGitHub = require('./lib/publish');
const successGitHub = require('./lib/success');
const failGitHub = require('./lib/fail');
let verified;
async function verifyConditions(pluginConfig, context) {
const {options} = context;
// If the GitHub publish plugin is used and has `assets`, `successComment`, `failComment`, `failTitle`, `labels` or `assignees` configured, validate it now in order to prevent any release if the configuration is wrong
if (options.publish) {
const publishPlugin =
(Array.isArray(options.publish) ? options.publish : [options.publish]).find(
config => config.path && config.path === '@semantic-release/github'
) || {};
pluginConfig.assets = pluginConfig.assets || publishPlugin.assets;
pluginConfig.successComment = pluginConfig.successComment || publishPlugin.successComment;
pluginConfig.failComment = pluginConfig.failComment || publishPlugin.failComment;
pluginConfig.failTitle = pluginConfig.failTitle || publishPlugin.failTitle;
pluginConfig.labels = pluginConfig.labels || publishPlugin.labels;
pluginConfig.assignees = pluginConfig.assignees || publishPlugin.assignees;
}
await verifyGitHub(pluginConfig, context);
verified = true;
}
async function publish(pluginConfig, context) {
if (!verified) {
await verifyGitHub(pluginConfig, context);
verified = true;
}
return publishGitHub(pluginConfig, context);
}
async function success(pluginConfig, context) {
if (!verified) {
await verifyGitHub(pluginConfig, context);
verified = true;
}
await successGitHub(pluginConfig, context);
}
async function fail(pluginConfig, context) {
if (!verified) {
await verifyGitHub(pluginConfig, context);
verified = true;
}
await failGitHub(pluginConfig, context);
}
module.exports = {verifyConditions, publish, success, fail};