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

Function parseChangelog

scripts/changes/changes.ts:620–649  ·  view source on GitHub ↗

* Parses a package's CHANGELOG.md and returns all version entries

(packageDirName: string)

Source from the content-addressed store, hash-verified

618 * Parses a package's CHANGELOG.md and returns all version entries
619 */
620function parseChangelog(packageDirName: string): AllChangelogEntries | null {
621 let changelogPath = getPackageFile(packageDirName, "CHANGELOG.md");
622
623 if (!fileExists(changelogPath)) {
624 return null;
625 }
626
627 let changelog = readFile(changelogPath);
628 let parser = /^## ([a-z\d.-]+)(?: \(([^)]+)\))?$/gim;
629
630 let result: AllChangelogEntries = {};
631
632 let match;
633 while ((match = parser.exec(changelog))) {
634 let [, versionString, dateString] = match;
635 let lastIndex = parser.lastIndex;
636 let version = versionString.startsWith("v")
637 ? versionString.slice(1)
638 : versionString;
639 let date = dateString ? new Date(dateString) : undefined;
640 let nextMatch = parser.exec(changelog);
641 let body = changelog
642 .slice(lastIndex, nextMatch ? nextMatch.index : undefined)
643 .trim();
644 result[version] = { version, date, body };
645 parser.lastIndex = lastIndex;
646 }
647
648 return result;
649}
650
651/**
652 * Gets a specific version's entry from a package's CHANGELOG.md.

Callers 1

getChangelogEntryFunction · 0.85

Calls 3

getPackageFileFunction · 0.90
fileExistsFunction · 0.90
readFileFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…