Skip to content

Commit

Permalink
fix: use URL construction method correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoVazquez committed Feb 3, 2023
1 parent 85c06a4 commit cd25d60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
18 changes: 9 additions & 9 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ interface BuildConfig {
export function getAdapter(isModeDirectory: boolean): AstroAdapter {
return isModeDirectory
? {
name: '@astrojs/cloudflare',
serverEntrypoint: '@astrojs/cloudflare/server.directory.js',
exports: ['onRequest'],
}
name: '@astrojs/cloudflare',
serverEntrypoint: '@astrojs/cloudflare/server.directory.js',
exports: ['onRequest'],
}
: {
name: '@astrojs/cloudflare',
serverEntrypoint: '@astrojs/cloudflare/server.advanced.js',
exports: ['default'],
};
name: '@astrojs/cloudflare',
serverEntrypoint: '@astrojs/cloudflare/server.advanced.js',
exports: ['default'],
};
}

const SHIM = `globalThis.process = {
Expand Down Expand Up @@ -203,7 +203,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
}

if (isModeDirectory) {
const functionsUrl = new URL(`file://${_config.root}/functions/`);
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
5 changes: 1 addition & 4 deletions packages/integrations/cloudflare/test/directory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { loadFixture } from './test-utils.js';
import { expect } from 'chai';
import cloudflare from '../dist/index.js';

/** @type {import('./test-utils').Fixture} */
describe('mode: "directory"', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;

before(async () => {
Expand All @@ -16,9 +16,6 @@ describe('mode: "directory"', () => {
});

it('generates the functions folder on under the config root', async () => {
// const functions = await fixture.readFile('/_routes.json')
// expect(routes.exclude).to.include('/one/');
console.log(await fixture.readdir('../../basics'));
expect(await fixture.pathExists('../functions')).to.be.true;
});
});

0 comments on commit cd25d60

Please sign in to comment.