diff --git a/.changeset/famous-peas-punch.md b/.changeset/famous-peas-punch.md new file mode 100644 index 0000000000..0c8b795b72 --- /dev/null +++ b/.changeset/famous-peas-punch.md @@ -0,0 +1,5 @@ +--- +"@pnpm/default-reporter": minor +--- + +Scope is not reported when the scope is only one project. diff --git a/packages/default-reporter/src/reporterForClient/reportScope.ts b/packages/default-reporter/src/reporterForClient/reportScope.ts index adad0b7e72..ef9e1bc381 100644 --- a/packages/default-reporter/src/reporterForClient/reportScope.ts +++ b/packages/default-reporter/src/reporterForClient/reportScope.ts @@ -27,9 +27,8 @@ export default ( return scope$.pipe( take(1), map((log) => { - if (log.selected === 1 && typeof log.total !== 'number') { - if (!log.workspacePrefix) return Rx.NEVER - if (!opts.isRecursive) return Rx.of({ msg: 'Scope: current workspace package' }) + if (log.selected === 1) { + return Rx.NEVER } let msg = 'Scope: ' diff --git a/packages/default-reporter/test/reportingScope.ts b/packages/default-reporter/test/reportingScope.ts index 850ba14d82..e6a9ec5892 100644 --- a/packages/default-reporter/test/reportingScope.ts +++ b/packages/default-reporter/test/reportingScope.ts @@ -3,12 +3,13 @@ import { toOutput$ } from '@pnpm/default-reporter' import logger, { createStreamParser, } from '@pnpm/logger' +import delay from 'delay' import { take } from 'rxjs/operators' import test = require('tape') const scopeLogger = logger('scope') -test('prints scope of non-recursive install in a workspace', (t) => { +test('does not print scope of non-recursive install in a workspace', async (t) => { const output$ = toOutput$({ context: { argv: ['install'], @@ -23,13 +24,17 @@ test('prints scope of non-recursive install in a workspace', (t) => { t.plan(1) - output$.pipe(take(1)).subscribe({ + const subscription = output$.subscribe({ complete: () => t.end(), error: t.end, - next: output => { - t.equal(output, 'Scope: current workspace package') + next: () => { + t.fail('should not log anything') }, }) + + await delay(10) + t.ok('output$ has no event') + subscription.unsubscribe() }) test('prints scope of recursive install in a workspace when not all packages are selected', (t) => { @@ -42,7 +47,7 @@ test('prints scope of recursive install in a workspace when not all packages are }) scopeLogger.debug({ - selected: 1, + selected: 2, total: 10, workspacePrefix: '/home/src', }) @@ -53,7 +58,7 @@ test('prints scope of recursive install in a workspace when not all packages are complete: () => t.end(), error: t.end, next: output => { - t.equal(output, 'Scope: 1 of 10 workspace projects') + t.equal(output, 'Scope: 2 of 10 workspace projects') }, }) }) @@ -94,7 +99,7 @@ test('prints scope of recursive install not in a workspace when not all packages }) scopeLogger.debug({ - selected: 1, + selected: 2, total: 10, }) @@ -104,7 +109,7 @@ test('prints scope of recursive install not in a workspace when not all packages complete: () => t.end(), error: t.end, next: output => { - t.equal(output, 'Scope: 1 of 10 projects') + t.equal(output, 'Scope: 2 of 10 projects') }, }) })