forked from XZB-1248/Spark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.js
27 lines (26 loc) · 795 Bytes
/
release.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
const process = require("process");
const fs = require("fs");
let changelogs = fs.readFileSync("CHANGELOG.md", "utf-8").toString().split("\n\n\n\n");
if (changelogs.length === 0) {
console.error("Failed to read CHANGELOG.md.");
process.exit(1);
}
let generated = false;
for (let i = 0; i < changelogs.length; i++) {
let thisNotes = changelogs[i].split("\n");
if (thisNotes.length === 0) {
continue;
}
if (!thisNotes.shift().endsWith(process.argv[2])) {
continue
}
thisNotes.shift();
fs.writeFileSync("CHANGELOG.md", thisNotes.join("\n"));
generated = true;
break
}
if (!generated) {
console.log(`Failed to find version ${process.argv[2]} in current changelog.`);
process.exit(1);
}
console.log("New CHANGELOG.md generated.");