mirror of
https://github.com/certd/certd.git
synced 2026-04-03 14:10:54 +08:00
32 lines
997 B
JavaScript
32 lines
997 B
JavaScript
import fs from 'fs'
|
|
|
|
|
|
|
|
export function getVersionContent() {
|
|
// CHANGELOG.md
|
|
const changelog = fs.readFileSync('./CHANGELOG.md', 'utf8')
|
|
// 解析CHANGELOG.md
|
|
let lines = changelog.split('\n')
|
|
const versionLineIndex = lines.findIndex(line => {
|
|
return line.startsWith('## [') || line.startsWith('# [')
|
|
})
|
|
const versionLine = lines[versionLineIndex]
|
|
// ## [1.37.16](https://github.com/certd/certd/compare/v1.37.15...v1.37.16) (2025-12-15)
|
|
const versionTitle = versionLine.match(/\[(.*?)\]/)[1]
|
|
|
|
const contentStart = versionLineIndex + 1
|
|
lines = lines.slice(contentStart)
|
|
const contentEnd = lines.findIndex(line => {
|
|
return line.startsWith('## [') || line.startsWith('# [')
|
|
})
|
|
const content = lines.slice(0, contentEnd).join('\n')
|
|
console.log("-------title------/n")
|
|
console.log(versionTitle)
|
|
console.log("-------content------/n")
|
|
console.log(content)
|
|
|
|
return {
|
|
versionTitle,
|
|
content
|
|
}
|
|
} |