From 4cd84c660729108912870dc09d6da2cfdc72f386 Mon Sep 17 00:00:00 2001 From: Mats Date: Thu, 24 Jun 2021 23:07:49 +0200 Subject: [PATCH] Removed unused console.warn trap function (#537) --- .changeset/lazy-doors-watch.md | 5 +++++ packages/astro/src/build.ts | 4 +--- packages/astro/src/logger.ts | 10 ---------- 3 files changed, 6 insertions(+), 13 deletions(-) create mode 100644 .changeset/lazy-doors-watch.md diff --git a/.changeset/lazy-doors-watch.md b/.changeset/lazy-doors-watch.md new file mode 100644 index 000000000..ee5d045ab --- /dev/null +++ b/.changeset/lazy-doors-watch.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +#528 Removes unused trapWarn function diff --git a/packages/astro/src/build.ts b/packages/astro/src/build.ts index 1f11a6acf..fbe990169 100644 --- a/packages/astro/src/build.ts +++ b/packages/astro/src/build.ts @@ -18,7 +18,7 @@ import { buildCollectionPage, buildStaticPage, getPageType } from './build/page. import { generateSitemap } from './build/sitemap.js'; import { logURLStats, collectBundleStats, mapBundleStatsToURLStats } from './build/stats.js'; import { getDistPath, stopTimer } from './build/util.js'; -import { debug, defaultLogDestination, defaultLogLevel, error, info, warn, trapWarn } from './logger.js'; +import { debug, defaultLogDestination, defaultLogLevel, error, info, warn } from './logger.js'; import { createRuntime } from './runtime.js'; const defaultLogging: LogOptions = { @@ -71,7 +71,6 @@ export async function build(astroConfig: AstroConfig, logging: LogOptions = defa timer.build = performance.now(); const pages = await allPages(pagesRoot); info(logging, 'build', yellow('! building pages...')); - const release = trapWarn(); // Vue also console.warns, this silences it. await Promise.all( pages.map(async (filepath) => { const buildPage = getPageType(filepath) === 'collection' ? buildCollectionPage : buildStaticPage; @@ -88,7 +87,6 @@ export async function build(astroConfig: AstroConfig, logging: LogOptions = defa }) ); info(logging, 'build', green('✔'), 'pages built.'); - release(); debug(logging, 'build', `built pages [${stopTimer(timer.build)}]`); // after pages are built, build depTree diff --git a/packages/astro/src/logger.ts b/packages/astro/src/logger.ts index 6766c9b38..9123b4a2b 100644 --- a/packages/astro/src/logger.ts +++ b/packages/astro/src/logger.ts @@ -150,16 +150,6 @@ export const logger = { error: error.bind(null, defaultLogOptions), }; -/** For silencing libraries that go directly to console.warn */ -export function trapWarn(cb: (...args: any[]) => void = () => {}) { - /* eslint-disable no-console */ - const consoleWarn = console.warn; - console.warn = function (...args: any[]) { - cb(...args); - }; - return () => (console.warn = consoleWarn); -} - function padStr(str: string, len: number) { const strLen = stringWidth(str); if (strLen > len) {