()
| 11 | * Read all the changesets. |
| 12 | */ |
| 13 | export async function readAllNewChangsets() { |
| 14 | const allChangesetNames = (await readdir(changesetDir)) |
| 15 | .filter((file) => file.endsWith(".md")) |
| 16 | .map((file) => file.slice(0, -3)); |
| 17 | |
| 18 | const changesets = []; |
| 19 | |
| 20 | for (const newChangeSetName of allChangesetNames) { |
| 21 | const changesetFilePath = path.join(changesetDir, `${newChangeSetName}.md`); |
| 22 | |
| 23 | const changesetContent = await readFile(changesetFilePath, "utf-8"); |
| 24 | |
| 25 | const { content, frontMatter } = parseFrontMatter(changesetContent); |
| 26 | const commitHash = await getAddingCommit(changesetFilePath); |
| 27 | |
| 28 | changesets.push({ |
| 29 | frontMatter, |
| 30 | content, |
| 31 | path: changesetFilePath, |
| 32 | commitHash, |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | return changesets; |
| 37 | } |
| 38 | |
| 39 | export function parseFrontMatter(markdown: string) { |
| 40 | const match = markdown.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/); |
no test coverage detected