Skip to content

Commit 79b1fe8

Browse files
fix: replace all instances of old strings in setup script (#282)
* fix: replace all instances of old strings in setup script * autofix ESLint
1 parent 554e349 commit 79b1fe8

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,3 @@ Thanks! 💖
138138
<!-- spellchecker: enable -->
139139
<!-- markdownlint-restore -->
140140
<!-- prettier-ignore-end -->
141-
142-
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
143-
144-
> 💙 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

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* global $ */
2+
import { EOL } from "node:os";
23
import { parseArgs } from "node:util";
34

45
import chalk from "chalk";
@@ -107,18 +108,18 @@ try {
107108
);
108109

109110
for (const [from, to, files = ["./.github/**/*", "./*.*"]] of [
110-
[existingPackage.description, description],
111-
["Template TypeScript Node Package", title],
112-
["JoshuaKGoldberg", owner],
113-
["template-typescript-node-package", repository],
114-
[/"setup": ".*",/, ``, "./package.json"],
115-
[/"setup:test": ".*",/, ``, "./package.json"],
111+
[new RegExp(existingPackage.description, "g"), description],
112+
[/Template TypeScript Node Package/g, title],
113+
[/JoshuaKGoldberg/g, owner],
114+
[/template-typescript-node-package/g, repository],
115+
[/"setup": ".*",/g, ``, "./package.json"],
116+
[/"setup:test": ".*",/g, ``, "./package.json"],
116117
[
117-
`"version": "${existingPackage.version}"`,
118+
new RegExp(`"version": "${existingPackage.version}"`, "g"),
118119
`"version": "0.0.0"`,
119120
"./package.json",
120121
],
121-
[/## Explainer.*## Usage/s, `## Usage`, "./README.md"],
122+
[/## Explainer.*## Usage/gs, `## Usage`, "./README.md"],
122123
[
123124
`["src/index.ts!", "script/setup*.js"]`,
124125
`"src/index.ts!"`,
@@ -129,17 +130,27 @@ try {
129130
await replace({ files, from, to });
130131
}
131132

132-
const endOfReadmeNotice = `
133+
await fs.writeFile(
134+
".all-contributorsrc",
135+
prettier.format(
136+
JSON.stringify({
137+
...JSON.parse((await fs.readFile(".all-contributorsrc")).toString()),
138+
projectName: repository,
139+
projectOwner: owner,
140+
}),
141+
{ parser: "json" }
142+
)
143+
);
133144

134-
<!-- You can remove this notice if you don't want it 🙂 no worries! -->
135-
136-
> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).`;
145+
const endOfReadmeNotice = [
146+
``,
147+
`<!-- You can remove this notice if you don't want it 🙂 no worries! -->`,
148+
``,
149+
`> 💙 This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).`,
150+
``,
151+
].join(EOL);
137152

138-
if (
139-
!(await fs.readFile("./README.md")).toString().includes(endOfReadmeNotice)
140-
) {
141-
await fs.appendFile("./README.md", endOfReadmeNotice);
142-
}
153+
await fs.appendFile("./README.md", endOfReadmeNotice);
143154

144155
console.log(chalk.gray`✔️ Done.`);
145156

0 commit comments

Comments
 (0)