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

* Fix 6206: Cloudflare function path resolving one step above
This commit is contained in:
Marvin Frachet 2023-02-13 02:19:38 +01:00 committed by GitHub
parent 8b7cb64dad
commit 79f49acbe1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': patch
---
Fix path file that was generated outside the functions folder

View file

@ -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);
}

View file

@ -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;
});
});