mirror of
https://gitee.com/WeBank/fes.js.git
synced 2024-12-05 21:27:53 +08:00
24 lines
610 B
JavaScript
24 lines
610 B
JavaScript
|
#!/usr/bin/env node
|
||
|
|
||
|
import { readFileSync, writeFileSync } from "fs";
|
||
|
const tag = process.argv[2].replace("v", "");
|
||
|
const log = readFileSync("./CHANGELOG.md", { encoding: "utf-8" }).split("\n");
|
||
|
let result = "";
|
||
|
let inScope = false;
|
||
|
const regex = new RegExp(`^#+ \\[${tag}`);
|
||
|
for (let i = 0; i < log.length; i++) {
|
||
|
if (regex.test(log[i])) {
|
||
|
inScope = true;
|
||
|
result += log[i];
|
||
|
continue;
|
||
|
}
|
||
|
if (inScope && /^#+ \[/.test(log[i])) {
|
||
|
inScope = false;
|
||
|
break;
|
||
|
}
|
||
|
if(inScope){
|
||
|
result += `\n${log[i]}`;
|
||
|
}
|
||
|
}
|
||
|
writeFileSync(`notes-v${tag}.md`, result)
|