Skip to content

Commit

Permalink
fix(default-reporter): use loglevel to filter deprecation warnings (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
milahu authored and zkochan committed Apr 16, 2022
1 parent 275c405 commit 881f456
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-pigs-jump.md
@@ -0,0 +1,5 @@
---
"@pnpm/default-reporter": patch
---

hide "WARN deprecated" messages on loglevel error.
5 changes: 5 additions & 0 deletions packages/default-reporter/src/index.ts
Expand Up @@ -104,6 +104,11 @@ export function toOutput$ (
const progressPushStream = new Rx.Subject<logs.ProgressLog>()
const stagePushStream = new Rx.Subject<logs.StageLog>()
const deprecationPushStream = new Rx.Subject<logs.DeprecationLog>()
if (opts.reportingOptions?.logLevel === 'error') {
// disable logging
// calls to deprecationPushStream.next() will have no effect
deprecationPushStream.complete()
}
const summaryPushStream = new Rx.Subject<logs.SummaryLog>()
const lifecyclePushStream = new Rx.Subject<logs.LifecycleLog>()
const statsPushStream = new Rx.Subject<logs.StatsLog>()
Expand Down
30 changes: 30 additions & 0 deletions packages/pnpm/test/install/misc.ts
Expand Up @@ -459,3 +459,33 @@ test('installation fails with a timeout error', async () => {
execPnpm(['add', 'typescript@2.4.2', '--fetch-timeout=1', '--fetch-retries=0'])
).rejects.toThrow()
})

// integration test for packages/default-reporter/src/index.ts -> deprecationPushStream
// TODO: use a smaller package for testing deprecation
test('logLevel=error hides "WARN deprecated" messages', async () => {
prepare({
dependencies: {
express: '0.14.1',
},
})

const result = execPnpmSync(['install', '--loglevel', 'error', '--lockfile-only'])

expect(result.status).toBe(0)
expect(result.stdout.toString()).not.toContain('\u2009WARN\u2009 deprecated ')
})

// integration test for packages/default-reporter/src/index.ts -> deprecationPushStream
// TODO: use a smaller package for testing deprecation
test('logLevel=warn shows "WARN deprecated" messages', async () => {
prepare({
dependencies: {
express: '0.14.1',
},
})

const result = execPnpmSync(['install', '--loglevel', 'warn', '--lockfile-only'])

expect(result.status).toBe(0)
expect(result.stdout.toString()).toContain('\u2009WARN\u2009 deprecated ')
})

0 comments on commit 881f456

Please sign in to comment.