mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Removed unused console.warn trap function (#537)
This commit is contained in:
parent
feb9a3141e
commit
4cd84c6607
3 changed files with 6 additions and 13 deletions
5
.changeset/lazy-doors-watch.md
Normal file
5
.changeset/lazy-doors-watch.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
#528 Removes unused trapWarn function
|
|
@ -18,7 +18,7 @@ import { buildCollectionPage, buildStaticPage, getPageType } from './build/page.
|
||||||
import { generateSitemap } from './build/sitemap.js';
|
import { generateSitemap } from './build/sitemap.js';
|
||||||
import { logURLStats, collectBundleStats, mapBundleStatsToURLStats } from './build/stats.js';
|
import { logURLStats, collectBundleStats, mapBundleStatsToURLStats } from './build/stats.js';
|
||||||
import { getDistPath, stopTimer } from './build/util.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';
|
import { createRuntime } from './runtime.js';
|
||||||
|
|
||||||
const defaultLogging: LogOptions = {
|
const defaultLogging: LogOptions = {
|
||||||
|
@ -71,7 +71,6 @@ export async function build(astroConfig: AstroConfig, logging: LogOptions = defa
|
||||||
timer.build = performance.now();
|
timer.build = performance.now();
|
||||||
const pages = await allPages(pagesRoot);
|
const pages = await allPages(pagesRoot);
|
||||||
info(logging, 'build', yellow('! building pages...'));
|
info(logging, 'build', yellow('! building pages...'));
|
||||||
const release = trapWarn(); // Vue also console.warns, this silences it.
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async (filepath) => {
|
pages.map(async (filepath) => {
|
||||||
const buildPage = getPageType(filepath) === 'collection' ? buildCollectionPage : buildStaticPage;
|
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.');
|
info(logging, 'build', green('✔'), 'pages built.');
|
||||||
release();
|
|
||||||
debug(logging, 'build', `built pages [${stopTimer(timer.build)}]`);
|
debug(logging, 'build', `built pages [${stopTimer(timer.build)}]`);
|
||||||
|
|
||||||
// after pages are built, build depTree
|
// after pages are built, build depTree
|
||||||
|
|
|
@ -150,16 +150,6 @@ export const logger = {
|
||||||
error: error.bind(null, defaultLogOptions),
|
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) {
|
function padStr(str: string, len: number) {
|
||||||
const strLen = stringWidth(str);
|
const strLen = stringWidth(str);
|
||||||
if (strLen > len) {
|
if (strLen > len) {
|
||||||
|
|
Loading…
Reference in a new issue