mirror of
https://gitee.com/WeBank/fes.js.git
synced 2024-11-30 02:37:52 +08:00
24 lines
610 B
JavaScript
Executable File
24 lines
610 B
JavaScript
Executable File
#!/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)
|