axios-miniprogram/scripts/releaselog.ts

29 lines
751 B
TypeScript
Raw Normal View History

2023-04-05 08:40:00 +08:00
import fs from 'node:fs';
import path from 'node:path';
import readline from 'node:readline';
import { __dirname, getPkgJSON } from './utils';
const changelogPath = path.resolve(__dirname, 'CHANGELOG.md');
const releaselogPath = path.resolve(__dirname, 'RELEASELOG.md');
const { version } = getPkgJSON();
2023-04-06 13:41:34 +08:00
const versionRE = new RegExp(`^# \\[?${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) {
if (line.startsWith('# ') && !versionRE.test(line)) {
break;
}
releaselog += `${line}\n`;
}
fs.writeFileSync(releaselogPath, releaselog);
}