Skip to content

Commit

Permalink
Fix 6206: Cloudflare function path resolving one step above
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrachet committed Feb 10, 2023
1 parent 8b7cb64 commit b9681c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/integrations/cloudflare/test/directory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

0 comments on commit b9681c6

Please sign in to comment.