[ci] format

This commit is contained in:
matthewp 2023-06-29 20:21:41 +00:00 committed by astrobot-houston
parent 154af8f5ea
commit 7ae6e89292
3 changed files with 10 additions and 14 deletions

View file

@ -228,8 +228,8 @@ export default defineConfig({
output: 'server',
adapter: vercel(),
build: {
split: true
}
split: true,
},
});
```

View file

@ -1,6 +1,7 @@
import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro';
import glob from 'fast-glob';
import { basename } from 'node:path';
import { pathToFileURL } from 'url';
import {
defaultImageConfig,
@ -12,7 +13,6 @@ import { exposeEnv } from '../lib/env.js';
import { getVercelOutput, removeDir, writeJson } from '../lib/fs.js';
import { copyDependenciesToFunction } from '../lib/nft.js';
import { getRedirects } from '../lib/redirects.js';
import { basename } from 'node:path';
const PACKAGE_NAME = '@astrojs/vercel/serverless';
@ -130,13 +130,13 @@ export default function vercelServerless({
const routeDefinitions: { src: string; dest: string }[] = [];
// Multiple entrypoint support
if(_entryPoints.size) {
for(const [route, entryFile] of _entryPoints) {
if (_entryPoints.size) {
for (const [route, entryFile] of _entryPoints) {
const func = basename(entryFile.toString()).replace(/\.mjs$/, '');
await createFunctionFolder(func, entryFile, inc);
routeDefinitions.push({
src: route.pattern.source,
dest: func
dest: func,
});
}
} else {
@ -148,11 +148,7 @@ export default function vercelServerless({
// https://vercel.com/docs/build-output-api/v3#build-output-configuration
await writeJson(new URL(`./config.json`, _config.outDir), {
version: 3,
routes: [
...getRedirects(routes, _config),
{ handle: 'filesystem' },
...routeDefinitions
],
routes: [...getRedirects(routes, _config), { handle: 'filesystem' }, ...routeDefinitions],
...(imageService || imagesConfig
? { images: imagesConfig ? imagesConfig : defaultImageConfig }
: {}),

View file

@ -11,13 +11,13 @@ describe('build: split', () => {
output: 'server',
build: {
split: true,
}
},
});
await fixture.build();
});
it('creates separate functions for each page', async () => {
const files = await fixture.readdir('../.vercel/output/functions/')
const files = await fixture.readdir('../.vercel/output/functions/');
expect(files.length).to.equal(2);
});
@ -25,5 +25,5 @@ describe('build: split', () => {
const json = await fixture.readFile('../.vercel/output/config.json');
const config = JSON.parse(json);
expect(config.routes).to.have.a.lengthOf(3);
})
});
});