Skip to content

Commit 59026eb

Browse files
fix: detect additional content after ALL-CONTRIBUTORS-LIST:END (#2103)
## PR Checklist - [x] Addresses an existing open issue: fixes #2102 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview 🎁
1 parent d8840d3 commit 59026eb

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/options/readReadmeAdditional.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,35 @@ After.
3535
expect(result).toBe("After.");
3636
});
3737

38-
it("returns all content after contributors when there is a comment template notice", async () => {
38+
it("returns all content after contributors when there is a spellchecker comment template notice", async () => {
3939
const getReadme = () =>
4040
Promise.resolve(`# My Package
4141
4242
Usage.
4343
44+
<!-- ALL-CONTRIBUTORS-LIST:END -->
4445
<!-- spellchecker:enable -->
4546
4647
After.
4748
49+
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
50+
`);
51+
52+
const result = await readReadmeAdditional(getReadme);
53+
54+
expect(result).toBe("After.");
55+
});
56+
57+
it("returns all content after contributors when there is a contributors comment template notice", async () => {
58+
const getReadme = () =>
59+
Promise.resolve(`# My Package
60+
61+
Usage.
62+
63+
<!-- ALL-CONTRIBUTORS-LIST:END -->
64+
65+
After.
66+
4867
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
4968
`);
5069

src/options/readReadmeAdditional.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
const indicatorAfterContributors = /<!--\s*spellchecker:\s*enable\s*-->/;
1+
const indicatorAfterAllContributors = /<!--\s*ALL-CONTRIBUTORS-LIST:END\s*-->/;
2+
const indicatorAfterAllContributorsSpellCheck =
3+
/<!--\s*spellchecker:\s*enable\s*-->/;
24

35
const indicatorBeforeTemplatedBy =
46
/> .* This package was templated with |<!-- You can remove this notice/;
@@ -9,7 +11,9 @@ export async function readReadmeAdditional(getReadme: () => Promise<string>) {
911
return undefined;
1012
}
1113

12-
const indexAfterContributors = indicatorAfterContributors.exec(readme);
14+
const indexAfterContributors =
15+
indicatorAfterAllContributorsSpellCheck.exec(readme) ??
16+
indicatorAfterAllContributors.exec(readme);
1317
if (!indexAfterContributors) {
1418
return undefined;
1519
}

0 commit comments

Comments
 (0)