Skip to content

Commit

Permalink
Fix 6206: Cloudflare function path resolving one step above (#6208)
Browse files Browse the repository at this point in the history
* Fix 6206: Cloudflare function path resolving one step above
  • Loading branch information
mfrachet authored Feb 13, 2023
1 parent 8b7cb64 commit 79f49ac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lazy-coins-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---

Fix path file that was generated outside the functions folder
3 changes: 2 additions & 1 deletion packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
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 79f49ac

Please sign in to comment.