From 06f2aaf91e89bf5d47f34336e5fecbcde3c3f2f7 Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Wed, 30 Mar 2022 16:05:04 +0200 Subject: [PATCH] fix(default-reporter): use loglevel to filter deprecation warnings (#4343) --- packages/default-reporter/src/reporterForClient/index.ts | 6 +++++- .../src/reporterForClient/reportDeprecations.ts | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/default-reporter/src/reporterForClient/index.ts b/packages/default-reporter/src/reporterForClient/index.ts index dc061c57bca..fd7582cfd08 100644 --- a/packages/default-reporter/src/reporterForClient/index.ts +++ b/packages/default-reporter/src/reporterForClient/index.ts @@ -75,7 +75,11 @@ export default function ( cwd, width, }), - reportDeprecations(log$.deprecation, { cwd, isRecursive: opts.isRecursive }), + reportDeprecations(log$.deprecation, { + cwd, + isRecursive: opts.isRecursive, + logLevel: opts.logLevel, + }), reportMisc( log$, { diff --git a/packages/default-reporter/src/reporterForClient/reportDeprecations.ts b/packages/default-reporter/src/reporterForClient/reportDeprecations.ts index af1fbf09449..954e56c5090 100644 --- a/packages/default-reporter/src/reporterForClient/reportDeprecations.ts +++ b/packages/default-reporter/src/reporterForClient/reportDeprecations.ts @@ -1,18 +1,23 @@ import { DeprecationLog } from '@pnpm/core-loggers' import * as Rx from 'rxjs' -import { map } from 'rxjs/operators' +import { filter, map } from 'rxjs/operators' import chalk from 'chalk' import formatWarn from './utils/formatWarn' import { zoomOut } from './utils/zooming' +import type { LogLevel } from '@pnpm/logger' export default ( deprecation$: Rx.Observable, opts: { cwd: string isRecursive: boolean + logLevel?: LogLevel } ) => { return deprecation$.pipe( + // print deprecation warnings for all logLevel except error = warn info debug + // TODO unswitch -> return a "null pipe" + filter(() => opts.logLevel != 'error'), map((log) => { if (!opts.isRecursive && log.prefix === opts.cwd) { return Rx.of({