From b9681c681ad7ef6225966266407051e800345b9e Mon Sep 17 00:00:00 2001 From: mfrachet Date: Fri, 10 Feb 2023 13:24:27 +0100 Subject: [PATCH] Fix 6206: Cloudflare function path resolving one step above --- packages/integrations/cloudflare/src/index.ts | 5 +++-- packages/integrations/cloudflare/test/directory.test.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 7ba1cc63148a..aadcd3c6daa6 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -205,8 +205,9 @@ export default function createIntegration(args?: Options): AstroIntegration { if (isModeDirectory) { 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); + + const directoryUrl = new URL('functions/[[path]].js', _config.root); + await fs.promises.rename(finalBuildUrl, directoryUrl.pathname); } }, }, diff --git a/packages/integrations/cloudflare/test/directory.test.js b/packages/integrations/cloudflare/test/directory.test.js index e5b5205745cf..67693310a7e0 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; }); });