Skip to content

Commit 75be0d5

Browse files
authored
fix(create-cloudflare): add a newline character to the line prepended to wrangler.toml (#7457)
* fix(create-cloudflare): add a newline character to the line prepended to wrangler.toml * add changeset
1 parent 5f6e9c1 commit 75be0d5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

.changeset/large-mails-relax.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": patch
3+
---
4+
5+
fix(create-cloudflare): add a newline character to the line prepended to wrangler.toml

packages/create-cloudflare/src/wrangler/__tests__/config.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ describe("updateWranglerToml", () => {
7373
await updateWranglerToml(ctx);
7474

7575
const newToml = vi.mocked(writeFile).mock.calls[0][1];
76-
expect(newToml).toMatch(`name = "${ctx.project.name}"`);
77-
expect(newToml).toMatch(`main = "src/index.ts"`);
7876
expect(newToml).toBe(
79-
`compatibility_date = "2024-01-17"name = "test"\n` +
77+
`compatibility_date = "${mockCompatDate}"\n` +
78+
`name = "${ctx.project.name}"\n` +
8079
`main = "src/index.ts"`,
8180
);
8281
});
@@ -88,11 +87,10 @@ describe("updateWranglerToml", () => {
8887
await updateWranglerToml(ctx);
8988

9089
const newToml = vi.mocked(writeFile).mock.calls[0][1];
91-
expect(newToml).toMatch(`name = "${ctx.project.name}"`);
92-
expect(newToml).toMatch(`main = "src/index.ts"`);
93-
expect(newToml).toMatch(`compatibility_date = "${mockCompatDate}"`);
9490
expect(newToml).toBe(
95-
`name = "test"compatibility_date = "2024-01-17"main = "src/index.ts"`,
91+
`name = "${ctx.project.name}"\n` +
92+
`compatibility_date = "${mockCompatDate}"\n` +
93+
`main = "src/index.ts"`,
9694
);
9795
});
9896

packages/create-cloudflare/src/wrangler/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ export const updateWranglerToml = async (ctx: C3Context) => {
3131
}
3232
} else {
3333
newToml.prepend(
34-
`compatibility_date = "${await getWorkerdCompatibilityDate()}"`,
34+
`compatibility_date = "${await getWorkerdCompatibilityDate()}"\n`,
3535
);
3636
}
3737

3838
const nameRe = /^name\s*=.*/m;
3939
if (wranglerToml.match(nameRe)) {
4040
newToml.replace(nameRe, `name = "${ctx.project.name}"`);
4141
} else {
42-
newToml.prepend(`name = "${ctx.project.name}"`);
42+
newToml.prepend(`name = "${ctx.project.name}"\n`);
4343
}
4444

4545
writeWranglerToml(ctx, newToml.toString());

0 commit comments

Comments
 (0)