vuecssuiant-designantdreactantantd-vueenterprisefrontendui-designvue-antdvue-antd-uivue3vuecomponent
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
640 B
24 lines
640 B
7 years ago
|
const fs = require('fs')
|
||
|
|
||
|
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
|
||
|
for (let i = 0; i < lines.length; i += 1) {
|
||
|
const line = lines[i]
|
||
|
if (begin && stopPattern.test(line)) {
|
||
|
break
|
||
|
}
|
||
|
if (begin && line && !skipPattern.test(line)) {
|
||
|
changeLog.push(line)
|
||
|
}
|
||
|
if (!begin) {
|
||
|
begin = startPattern.test(line)
|
||
|
}
|
||
|
}
|
||
|
return changeLog.join('\n')
|
||
|
}
|