2023-04-05 08:40:00 +08:00
|
|
|
import fs from 'node:fs';
|
|
|
|
import readline from 'node:readline';
|
2023-04-10 15:12:28 +08:00
|
|
|
import { getPkgJSON, resolve } from './utils';
|
2023-04-05 08:40:00 +08:00
|
|
|
|
2023-04-10 15:12:28 +08:00
|
|
|
const changelogPath = resolve('CHANGELOG.md');
|
|
|
|
const releaselogPath = resolve('RELEASELOG.md');
|
2023-04-05 08:40:00 +08:00
|
|
|
const { version } = getPkgJSON();
|
2023-04-26 09:57:28 +08:00
|
|
|
const versionRE = new RegExp(`^#{1,2} \\[?${version}\\]?\\(?`);
|
2023-04-05 08:40:00 +08:00
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const changelog = readline.createInterface({
|
|
|
|
input: fs.createReadStream(changelogPath),
|
|
|
|
crlfDelay: Infinity,
|
|
|
|
});
|
|
|
|
|
|
|
|
let releaselog = '';
|
|
|
|
for await (const line of changelog) {
|
2023-04-26 09:57:28 +08:00
|
|
|
if (/^#{1,2} /.test(line) && !versionRE.test(line)) {
|
2023-04-05 08:40:00 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
releaselog += `${line}\n`;
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFileSync(releaselogPath, releaselog);
|
|
|
|
}
|