MCPcopy Index your code
hub / github.com/remix-run/react-router / updateChangelog

Function updateChangelog

scripts/changes/version.ts:204–242  ·  view source on GitHub ↗

* Updates CHANGELOG.md with new content

(packageDirName: string, newContent: string)

Source from the content-addressed store, hash-verified

202 * Updates CHANGELOG.md with new content
203 */
204function updateChangelog(packageDirName: string, newContent: string) {
205 let changelogPath =
206 packageDirName === "/"
207 ? path.join(getRootDir(), "CHANGELOG.md")
208 : getPackageFile(packageDirName, "CHANGELOG.md");
209
210 if (preview) {
211 console.log(
212 ` • Would update ${path.relative(process.cwd(), changelogPath)}:\n`,
213 );
214 console.log(
215 newContent
216 .split("\n")
217 .map((line) => ` ${line}`)
218 .join("\n"),
219 );
220 return;
221 }
222
223 let existingChangelog = readFile(changelogPath);
224
225 let lines = existingChangelog.split("\n");
226
227 // Find the first ## version entry
228 let firstVersionIndex = lines.findIndex((line) => line.startsWith("## "));
229
230 let updatedChangelog: string;
231 if (firstVersionIndex !== -1) {
232 // Insert before the first version entry
233 lines.splice(firstVersionIndex, 0, newContent);
234 updatedChangelog = lines.join("\n");
235 } else {
236 // No version entries yet - append to the end
237 updatedChangelog = existingChangelog.trimEnd() + "\n\n" + newContent + "\n";
238 }
239
240 writeFile(changelogPath, updatedChangelog);
241 console.log(` ✓ Updated CHANGELOG.md`);
242}
243
244/**
245 * Deletes all change files (except README.md)

Callers 1

version.tsFile · 0.85

Calls 5

getRootDirFunction · 0.90
getPackageFileFunction · 0.90
readFileFunction · 0.90
writeFileFunction · 0.90
logMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…