[ci] yarn format

This commit is contained in:
matthewp 2022-01-13 14:24:25 +00:00 committed by GitHub Actions
parent 2aa5ba5c52
commit 365972582e
3 changed files with 25 additions and 27 deletions

View file

@ -7,15 +7,15 @@ import { fileURLToPath } from 'url';
export function emptyDir(dir: string, skip?: Set<string>): void { export function emptyDir(dir: string, skip?: Set<string>): void {
for (const file of fs.readdirSync(dir)) { for (const file of fs.readdirSync(dir)) {
if (skip?.has(file)) { if (skip?.has(file)) {
continue continue;
} }
const abs = npath.resolve(dir, file) const abs = npath.resolve(dir, file);
// baseline is Node 12 so can't use rmSync :( // baseline is Node 12 so can't use rmSync :(
if (fs.lstatSync(abs).isDirectory()) { if (fs.lstatSync(abs).isDirectory()) {
emptyDir(abs) emptyDir(abs);
fs.rmdirSync(abs) fs.rmdirSync(abs);
} else { } else {
fs.unlinkSync(abs) fs.unlinkSync(abs);
} }
} }
} }

View file

@ -36,8 +36,6 @@ function addPageName(pathname: string, opts: StaticBuildOptions): void {
opts.pageNames.push(pathname.replace(/\/?$/, pathrepl).replace(/^\//, '')); opts.pageNames.push(pathname.replace(/\/?$/, pathrepl).replace(/^\//, ''));
} }
// Determines of a Rollup chunk is an entrypoint page. // Determines of a Rollup chunk is an entrypoint page.
function chunkIsPage(output: OutputAsset | OutputChunk, internals: BuildInternals) { function chunkIsPage(output: OutputAsset | OutputChunk, internals: BuildInternals) {
if (output.type !== 'chunk') { if (output.type !== 'chunk') {
@ -178,14 +176,16 @@ async function collectRenderers(opts: StaticBuildOptions): Promise<Renderer[]> {
// we need the ESM loaded version. This creates that. // we need the ESM loaded version. This creates that.
const viteLoadedRenderers = pageData.preload[0]; const viteLoadedRenderers = pageData.preload[0];
const renderers = await Promise.all(viteLoadedRenderers.map(async r => { const renderers = await Promise.all(
viteLoadedRenderers.map(async (r) => {
const mod = await import(r.serverEntry); const mod = await import(r.serverEntry);
return Object.create(r, { return Object.create(r, {
ssr: { ssr: {
value: mod.default value: mod.default,
} },
}) as Renderer; }) as Renderer;
})); })
);
return renderers; return renderers;
} }
@ -253,7 +253,7 @@ async function generatePath(pathname: string, opts: StaticBuildOptions, gopts: G
// This adds the page name to the array so it can be shown as part of stats. // This adds the page name to the array so it can be shown as part of stats.
addPageName(pathname, opts); addPageName(pathname, opts);
const [,mod] = pageData.preload; const [, mod] = pageData.preload;
try { try {
const [params, pageProps] = await getParamsAndProps({ const [params, pageProps] = await getParamsAndProps({

View file

@ -12,9 +12,7 @@ describe('Static build - frameworks', () => {
before(async () => { before(async () => {
fixture = await loadFixture({ fixture = await loadFixture({
projectRoot: './fixtures/static-build-frameworks/', projectRoot: './fixtures/static-build-frameworks/',
renderers: [ renderers: ['@astrojs/renderer-preact'],
'@astrojs/renderer-preact'
],
buildOptions: { buildOptions: {
experimentalStaticBuild: true, experimentalStaticBuild: true,
}, },