diff --git a/.changeset/lazy-coins-compete.md b/.changeset/lazy-coins-compete.md new file mode 100644 index 0000000000..04b23077df --- /dev/null +++ b/.changeset/lazy-coins-compete.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +Fix path file that was generated outside the functions folder diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 7ba1cc6314..0343e6e818 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -203,8 +203,9 @@ export default function createIntegration(args?: Options): AstroIntegration { } if (isModeDirectory) { - const functionsUrl = new URL('functions', _config.root); + const functionsUrl = new URL('functions/', _config.root); await fs.promises.mkdir(functionsUrl, { recursive: true }); + const directoryUrl = new URL('[[path]].js', functionsUrl); await fs.promises.rename(finalBuildUrl, directoryUrl); } diff --git a/packages/integrations/cloudflare/test/directory.test.js b/packages/integrations/cloudflare/test/directory.test.js index e5b5205745..67693310a7 100644 --- a/packages/integrations/cloudflare/test/directory.test.js +++ b/packages/integrations/cloudflare/test/directory.test.js @@ -17,5 +17,6 @@ describe('mode: "directory"', () => { it('generates functions folder inside the project root', async () => { expect(await fixture.pathExists('../functions')).to.be.true; + expect(await fixture.pathExists('../functions/[[path]].js')).to.be.true; }); });