Skip to content

Commit b1f96eb

Browse files
committed
fix: don't add "Created with Solid CLI" text if it's already there
1 parent 44725ab commit b1f96eb

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

packages/create/src/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import {
1212
VanillaTemplate,
1313
} from "./utils/constants";
1414
import { detectPackageManager } from "@solid-cli/utils/package-manager";
15-
import { insertAtEnd } from "@solid-cli/utils/fs";
1615
import { existsSync, writeFileSync } from "node:fs";
1716
import { join } from "node:path";
1817
import { createLibrary } from "./create-library";
18+
import { readFile, writeFile } from "node:fs/promises";
1919
export { createVanilla, createStart };
2020

2121
export const createSolid = (version: string) =>
@@ -133,11 +133,12 @@ export const createSolid = (version: string) =>
133133
// Add .gitignore
134134
writeFileSync(join(projectName, ".gitignore"), GIT_IGNORE);
135135
// Add "Created with Solid CLI" text to bottom of README
136-
if (existsSync(`${projectName}/README.md`))
137-
await insertAtEnd(
138-
`${projectName}/README.md`,
139-
"\n## This project was created with the [Solid CLI](https://github.com/solidjs-community/solid-cli)\n",
140-
);
136+
const readmePath = `${projectName}/README.md`;
137+
if (existsSync(readmePath)) {
138+
const contents = (await readFile(readmePath)).toString();
139+
if (!contents.includes("This project was created with the [Solid CLI]"))
140+
await writeFile(readmePath, contents + "\n## This project was created with the [Solid CLI](https://github.com/solidjs-community/solid-cli)\n")
141+
}
141142
// Next steps..
142143
const pM = detectPackageManager();
143144
p.note(

0 commit comments

Comments
 (0)