| 476 | } |
| 477 | |
| 478 | function prependDocsUpdate(version: string, docsUpdate: string) { |
| 479 | const changelogPath = join(ROOT, "docs", "changelog.mdx"); |
| 480 | const changelog = readFileSync(changelogPath, "utf-8"); |
| 481 | |
| 482 | if (changelog.includes(`label="HyperFrames v${version}"`)) { |
| 483 | console.log(`docs/changelog.mdx already has a v${version} entry; leaving it unchanged.`); |
| 484 | return; |
| 485 | } |
| 486 | |
| 487 | if (!changelog.includes(DOCS_MARKER)) { |
| 488 | fail(`Could not find insertion marker in ${changelogPath}`); |
| 489 | } |
| 490 | |
| 491 | const updated = changelog.replace(DOCS_MARKER, `${DOCS_MARKER}\n\n${docsUpdate}`); |
| 492 | writeFileSync(changelogPath, updated); |
| 493 | console.log(`Prepended v${version} to ${changelogPath}`); |
| 494 | } |
| 495 | |
| 496 | if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { |
| 497 | main(); |