summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar natemoo-re <natemoo-re@users.noreply.github.com> 2023-08-07 15:59:11 +0000
committerGravatar astrobot-houston <fred+astrobot@astro.build> 2023-08-07 15:59:11 +0000
commit1a24ea6b5a6d40391ebd810cc6a7c32b3d1e8c96 (patch)
treebb9d56ba12326aa15d682ccd8cb029e853b71aac
parent6cd7290d2c8380bdf4d7e36f3296948d10d5bc25 (diff)
downloadastro-1a24ea6b5a6d40391ebd810cc6a7c32b3d1e8c96.tar.gz
astro-1a24ea6b5a6d40391ebd810cc6a7c32b3d1e8c96.tar.zst
astro-1a24ea6b5a6d40391ebd810cc6a7c32b3d1e8c96.zip
[ci] format
-rw-r--r--packages/astro/src/core/build/static-build.ts9
-rw-r--r--packages/astro/test/units/build/static-build.test.js98
2 files changed, 56 insertions, 51 deletions
diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts
index 95027fd5b..28f496d91 100644
--- a/packages/astro/src/core/build/static-build.ts
+++ b/packages/astro/src/core/build/static-build.ts
@@ -445,10 +445,15 @@ export function makeAstroPageEntryPointFileName(
facadeModuleId: string,
routes: RouteData[]
) {
- const pageModuleId = facadeModuleId.replace(prefix, '').replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.');
+ const pageModuleId = facadeModuleId
+ .replace(prefix, '')
+ .replace(ASTRO_PAGE_EXTENSION_POST_PATTERN, '.');
const route = routes.find((routeData) => routeData.component === pageModuleId);
const name = route?.route ?? pageModuleId;
- return `pages${name.replace(/\/$/, '/index').replaceAll(/[\[\]]/g, '_').replaceAll('...', '---')}.astro.mjs`;
+ return `pages${name
+ .replace(/\/$/, '/index')
+ .replaceAll(/[\[\]]/g, '_')
+ .replaceAll('...', '---')}.astro.mjs`;
}
/**
diff --git a/packages/astro/test/units/build/static-build.test.js b/packages/astro/test/units/build/static-build.test.js
index 632b1c429..38896c5aa 100644
--- a/packages/astro/test/units/build/static-build.test.js
+++ b/packages/astro/test/units/build/static-build.test.js
@@ -2,57 +2,57 @@ import { expect } from 'chai';
import { makeAstroPageEntryPointFileName } from '../../../dist/core/build/static-build.js';
describe('astro/src/core/build', () => {
- describe('makeAstroPageEntryPointFileName', () => {
- const routes = [
- {
- route: '/',
- component: 'src/pages/index.astro',
- pathname: '/',
- },
- {
- route: '/injected',
- component: '../node_modules/my-dep/injected.astro',
- pathname: '/injected',
- },
- {
- route: '/injected-workspace',
- component: '../../packages/demo/[...all].astro',
- pathname: undefined,
- },
- {
- route: '/blog/[year]/[...slug]',
- component: 'src/pages/blog/[year]/[...slug].astro',
- pathname: undefined,
- },
- ]
+ describe('makeAstroPageEntryPointFileName', () => {
+ const routes = [
+ {
+ route: '/',
+ component: 'src/pages/index.astro',
+ pathname: '/',
+ },
+ {
+ route: '/injected',
+ component: '../node_modules/my-dep/injected.astro',
+ pathname: '/injected',
+ },
+ {
+ route: '/injected-workspace',
+ component: '../../packages/demo/[...all].astro',
+ pathname: undefined,
+ },
+ {
+ route: '/blog/[year]/[...slug]',
+ component: 'src/pages/blog/[year]/[...slug].astro',
+ pathname: undefined,
+ },
+ ];
- it('handles local pages', async () => {
- const input = '@astro-page:src/pages/index@_@astro';
- const output = 'pages/index.astro.mjs';
- const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output)
- });
+ it('handles local pages', async () => {
+ const input = '@astro-page:src/pages/index@_@astro';
+ const output = 'pages/index.astro.mjs';
+ const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
+ expect(result).to.equal(output);
+ });
- it('handles dynamic pages', async () => {
- const input = '@astro-page:src/pages/blog/[year]/[...slug]@_@astro';
- const output = 'pages/blog/_year_/_---slug_.astro.mjs';
- const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output)
- });
+ it('handles dynamic pages', async () => {
+ const input = '@astro-page:src/pages/blog/[year]/[...slug]@_@astro';
+ const output = 'pages/blog/_year_/_---slug_.astro.mjs';
+ const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
+ expect(result).to.equal(output);
+ });
- it('handles node_modules pages', async () => {
- const input = '@astro-page:../node_modules/my-dep/injected@_@astro';
- const output = 'pages/injected.astro.mjs';
- const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output)
- });
+ it('handles node_modules pages', async () => {
+ const input = '@astro-page:../node_modules/my-dep/injected@_@astro';
+ const output = 'pages/injected.astro.mjs';
+ const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
+ expect(result).to.equal(output);
+ });
- // Fix #7561
- it('handles local workspace pages', async () => {
- const input = '@astro-page:../../packages/demo/[...all]@_@astro';
- const output = 'pages/injected-workspace.astro.mjs';
- const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output)
- });
- });
+ // Fix #7561
+ it('handles local workspace pages', async () => {
+ const input = '@astro-page:../../packages/demo/[...all]@_@astro';
+ const output = 'pages/injected-workspace.astro.mjs';
+ const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
+ expect(result).to.equal(output);
+ });
+ });
});