Skip to content

Commit c6bbf49

Browse files
committed
fix: replace index.tsx with index.jsx in index.html
1 parent 30db179 commit c6bbf49

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/create/src/create-vanilla.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { downloadRepo, GithubFetcher } from "@begit/core";
22
import { join } from "node:path";
33
import { writeFileSync } from "node:fs";
4+
import { readFile } from "node:fs/promises";
45
import { handleTSConversion } from "./utils/ts-conversion";
56
import { GIT_IGNORE, VanillaTemplate } from "./utils/constants";
67

@@ -27,6 +28,9 @@ export const createVanillaJS = async ({ template, destination }: CreateVanillaAr
2728
const tempDir = join(destination, ".project");
2829
await createVanillaTS({ template, destination: tempDir });
2930
await handleTSConversion(tempDir, destination);
31+
// Replace `index.tsx` with `index.jsx` in `index.html`
32+
const indexPath = join(destination, "index.html");
33+
writeFileSync(indexPath, (await readFile(indexPath)).toString().replace("index.tsx", "index.jsx"));
3034
// Add .gitignore
3135
writeFileSync(join(destination, ".gitignore"), GIT_IGNORE);
3236
};

packages/create/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,21 @@ export const createSolid = (version: string) =>
7070
}),
7171
);
7272
// Don't offer javascript if `projectType` is library
73-
const useJS =
74-
projectType === "library" ? false : !(await cancelable(p.confirm({ message: "Use Typescript?" })));
73+
const useJS = projectType === "library" ? false : !(await cancelable(p.confirm({ message: "Use Typescript?" })));
7574

7675
const template_opts = getTemplatesList(projectType);
7776
template ??= await cancelable(
7877
p.select({
7978
message: "Which template would you like to use?",
8079
initialValue: "ts",
81-
options: template_opts.filter(s => useJS ? s : !s.startsWith("js")).map((s: string) => ({ label: s, value: s })),
80+
options: template_opts
81+
.filter((s) => (useJS ? s : !s.startsWith("js")))
82+
.map((s: string) => ({ label: s, value: s })),
8283
}),
8384
);
84-
85+
8586
// Need to transpile if the user wants Jabascript, but their selected template isn't Javascript
86-
const transpileToJS = useJS && !template.startsWith("js")
87+
const transpileToJS = useJS && !template.startsWith("js");
8788
if (projectType === "start") {
8889
await spinnerify({
8990
startText: "Creating project",

0 commit comments

Comments
 (0)