-
Notifications
You must be signed in to change notification settings - Fork 2
/
validateConfig.js
35 lines (28 loc) · 1.16 KB
/
validateConfig.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
function validateConfig(config) {
let valid = true;
const assert = (msg, rule) => {
if (!rule()) {
console.error(msg);
valid = false;
}
};
const release = config.release;
assert('Expected to see release section in package.json', () => release);
assert('Expected to see release.branchTags section in package.json', () =>
release.branchTags && Object.keys(release.branchTags).length > 0);
assert('Expected to see release.fallbackTags section in package.json', () =>
release.branchTags && Object.keys(release.fallbackTags).length > 0);
['generateNotes']
.forEach((plugin) => {
assert(`Expected release.${ plugin } to be set."`, () => Boolean(release[plugin]));
});
['analyzeCommits', 'getLastRelease', 'verifyConditions', 'verifyRelease']
.forEach((plugin) => {
assert(`Expected release.${ plugin } to be set to "@progress/semantic-prerelease/${ plugin }"`, () =>
release[plugin] == `@progress/semantic-prerelease/${ plugin }`);
});
if (!valid) {
process.exit(1);
}
}
module.exports = validateConfig;