Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(reporter): don't report scope when one project is selected #2855

Merged
merged 1 commit into from Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-peas-punch.md
@@ -0,0 +1,5 @@
---
"@pnpm/default-reporter": minor
---

Scope is not reported when the scope is only one project.
Expand Up @@ -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: '

Expand Down
21 changes: 13 additions & 8 deletions packages/default-reporter/test/reportingScope.ts
Expand Up @@ -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<object>('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'],
Expand All @@ -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) => {
Expand All @@ -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',
})
Expand All @@ -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')
},
})
})
Expand Down Expand Up @@ -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,
})

Expand All @@ -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')
},
})
})
Expand Down