From 4df98a79f8d5f14e9e049322a6eef2db4f985ae4 Mon Sep 17 00:00:00 2001 From: natemoo-re Date: Tue, 29 Jun 2021 16:38:55 +0000 Subject: [PATCH] [ci] yarn format --- packages/astro/src/build.ts | 45 ++++++++++++++----------- packages/astro/test/astro-throw.test.js | 5 ++- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/packages/astro/src/build.ts b/packages/astro/src/build.ts index 81d86ddb4d..073dbd2c33 100644 --- a/packages/astro/src/build.ts +++ b/packages/astro/src/build.ts @@ -73,30 +73,37 @@ export async function build(astroConfig: AstroConfig, logging: LogOptions = defa info(logging, 'build', yellow('! building pages...')); try { await Promise.all( - pages.map((filepath) => { - const buildPage = getPageType(filepath) === 'collection' ? buildCollectionPage : buildStaticPage; - return buildPage({ - astroConfig, - buildState, - filepath, - logging, - mode, - resolvePackageUrl: (pkgName: string) => snowpack.getUrlForPackage(pkgName), - runtime, - site: astroConfig.buildOptions.site, - }); - }) - ) + pages.map((filepath) => { + const buildPage = getPageType(filepath) === 'collection' ? buildCollectionPage : buildStaticPage; + return buildPage({ + astroConfig, + buildState, + filepath, + logging, + mode, + resolvePackageUrl: (pkgName: string) => snowpack.getUrlForPackage(pkgName), + runtime, + site: astroConfig.buildOptions.site, + }); + }) + ); } catch (e) { if (e.filename) { - let stack = e.stack.replace(/Object\.__render \(/gm, '').replace(/\/_astro\/(.+)\.astro\.js\:\d+\:\d+\)/gm, (_: string, $1: string) => 'file://' + fileURLToPath(projectRoot) + $1 + '.astro').split('\n'); - stack.splice(1, 0, ` at file://${e.filename}`) - stack = stack.join('\n') + let stack = e.stack + .replace(/Object\.__render \(/gm, '') + .replace(/\/_astro\/(.+)\.astro\.js\:\d+\:\d+\)/gm, (_: string, $1: string) => 'file://' + fileURLToPath(projectRoot) + $1 + '.astro') + .split('\n'); + stack.splice(1, 0, ` at file://${e.filename}`); + stack = stack.join('\n'); - error(logging, 'build', `${red(`Unable to render ${underline(e.filename.replace(fileURLToPath(projectRoot), ''))}`)} + error( + logging, + 'build', + `${red(`Unable to render ${underline(e.filename.replace(fileURLToPath(projectRoot), ''))}`)} ${stack} -`); +` + ); } else { error(logging, 'build', e); } diff --git a/packages/astro/test/astro-throw.test.js b/packages/astro/test/astro-throw.test.js index 702828187a..016804dc1d 100644 --- a/packages/astro/test/astro-throw.test.js +++ b/packages/astro/test/astro-throw.test.js @@ -19,10 +19,9 @@ Throwable('Can throw an error from an `.astro` file', async ({ runtime }) => { }); Throwable('Does not complete build when Error is thrown', async ({ build }) => { - await build().catch(e => { + await build().catch((e) => { assert.ok(e, 'Build threw'); - }) + }); }); - Throwable.run();