1 |
|
2 |
|
3 | const {defaultTo, castArray} = require('lodash');
|
4 | const verifyChangelog = require('./lib/verify.js');
|
5 | const prepareChangelog = require('./lib/prepare.js');
|
6 |
|
7 | let verified;
|
8 |
|
9 | async function verifyConditions(pluginConfig, context) {
|
10 | const {options} = context;
|
11 |
|
12 | if (options.prepare) {
|
13 | const preparePlugin =
|
14 | castArray(options.prepare).find((config) => config.path && config.path === '@semantic-release/changelog') || {};
|
15 |
|
16 | pluginConfig.changelogFile = defaultTo(pluginConfig.changelogFile, preparePlugin.changelogFile);
|
17 | }
|
18 |
|
19 | await verifyChangelog(pluginConfig);
|
20 | verified = true;
|
21 | }
|
22 |
|
23 | async function prepare(pluginConfig, context) {
|
24 | if (!verified) {
|
25 | await verifyChangelog(pluginConfig);
|
26 | verified = true;
|
27 | }
|
28 |
|
29 | await prepareChangelog(pluginConfig, context);
|
30 | }
|
31 |
|
32 | module.exports = {verifyConditions, prepare};
|