diff options
author | 2021-06-29 16:38:55 +0000 | |
---|---|---|
committer | 2021-06-29 16:38:55 +0000 | |
commit | 4df98a79f8d5f14e9e049322a6eef2db4f985ae4 (patch) | |
tree | 51231a10c969f7d2fff48be78905c05cb15bd0fc | |
parent | e28d5cb9dededa8e8eb42598b48f43b99b05dd2c (diff) | |
download | astro-4df98a79f8d5f14e9e049322a6eef2db4f985ae4.tar.gz astro-4df98a79f8d5f14e9e049322a6eef2db4f985ae4.tar.zst astro-4df98a79f8d5f14e9e049322a6eef2db4f985ae4.zip |
[ci] yarn format
-rw-r--r-- | packages/astro/src/build.ts | 45 | ||||
-rw-r--r-- | 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 81d86ddb4..073dbd2c3 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 702828187..016804dc1 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(); |