[ci] format

This commit is contained in:
natemoo-re 2023-08-07 15:59:11 +00:00 committed by astrobot-houston
parent 6cd7290d2c
commit 1a24ea6b5a
2 changed files with 56 additions and 51 deletions

View file

@ -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`;
}
/**

View file

@ -24,27 +24,27 @@ describe('astro/src/core/build', () => {
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)
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)
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)
expect(result).to.equal(output);
});
// Fix #7561
@ -52,7 +52,7 @@ describe('astro/src/core/build', () => {
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)
expect(result).to.equal(output);
});
});
});