🌈 An enterprise-class UI components based on Ant Design and Vue. 🐜
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
652 B

const fs = require('fs');
7 years ago
module.exports = function getChangelog(file, version) {
const lines = fs.readFileSync(file).toString().split('\n');
const changeLog = [];
const startPattern = new RegExp(`^## ${version}`);
const stopPattern = /^## /; // 前一个版本
const skipPattern = /^`/; // 日期
let begin = false;
7 years ago
for (let i = 0; i < lines.length; i += 1) {
const line = lines[i];
7 years ago
if (begin && stopPattern.test(line)) {
break;
7 years ago
}
if (begin && line && !skipPattern.test(line)) {
changeLog.push(line);
7 years ago
}
if (!begin) {
begin = startPattern.test(line);
7 years ago
}
}
return changeLog.join('\n');
};