Skip to content

Commit bd2901d

Browse files
fix: only append README.md notice once in setup (#131)
1 parent 722cfac commit bd2901d

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,7 @@ Thanks! 💖
103103
<!-- spellchecker: enable -->
104104
<!-- markdownlint-restore -->
105105
<!-- prettier-ignore-end -->
106+
107+
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
108+
109+
> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).

script/setup.js

+12-9
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,22 @@ try {
126126
"./package.json",
127127
],
128128
[/## Explainer.*## Usage/s, `## Usage`, "./README.md"],
129-
[
130-
"<!-- ALL-CONTRIBUTORS-LIST:END -->",
131-
`<!-- ALL-CONTRIBUTORS-LIST:END -->
132-
133-
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
134-
135-
> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).`,
136-
"./README.md",
137-
],
138129
]) {
139130
await replace({ files, from, to });
140131
}
141132

133+
const endOfReadmeNotice = `
134+
135+
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
136+
137+
> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).`;
138+
139+
if (
140+
!(await fs.readFile("./README.md")).toString().includes(endOfReadmeNotice)
141+
) {
142+
await fs.appendFile("./README.md", endOfReadmeNotice);
143+
}
144+
142145
console.log(chalk.gray`✔️ Done.`);
143146

144147
console.log();

0 commit comments

Comments
 (0)