-
Notifications
You must be signed in to change notification settings - Fork 399
/
Copy pathcreate-changelog.js
45 lines (39 loc) · 1.42 KB
/
create-changelog.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
const changelog = require('../CHANGELOG.json');
const fs = require('fs');
if (changelog.versions && changelog.versions.length > 0) {
const markdown = [];
markdown.push(`# Releases`);
markdown.push(``);
// Loop over all the change log versions
for (const entry of changelog.versions) {
markdown.push(`## ${entry.version}`);
markdown.push(``);
// Check if entry contains change information
if (entry.changes) {
// Loop over all change types
for (const changeName in entry.changes) {
const typeChanges = entry.changes[changeName];
if (typeChanges.length > 0) {
let name = changeName === "new" ? "new control(s)" : changeName;
markdown.push(`### ${name.charAt(0).toUpperCase() + name.slice(1)}`);
markdown.push(``);
// Add each change text
for (const msg of typeChanges) {
markdown.push(`- ${msg}`);
}
markdown.push(``);
}
}
}
// Add the contributions to the MD file
if (entry.contributions && entry.contributions.length > 0) {
markdown.push(`### Contributors`);
markdown.push(``);
markdown.push(`Special thanks to our contributor${entry.contributions.length > 1 ? "s (in alphabetical order)" : "" }: ${entry.contributions.join(', ')}.`);
markdown.push(``);
}
}
if (markdown.length > 2) {
fs.writeFileSync('CHANGELOG.md', markdown.join('\n'));
}
}