Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 6206: Cloudflare function path resolving one step above #6208

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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);
mfrachet marked this conversation as resolved.
Show resolved Hide resolved
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);
mfrachet marked this conversation as resolved.
Show resolved Hide resolved
await fs.promises.rename(finalBuildUrl, directoryUrl.pathname);
AirBorne04 marked this conversation as resolved.
Show resolved Hide resolved
}
},
},
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;
AirBorne04 marked this conversation as resolved.
Show resolved Hide resolved
});
});