mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-12 01:54:53 -04:00
@pnpm/cli.default-reporter
The default reporter of pnpm
Installation
pnpm add @pnpm/cli.default-reporter
Usage
import { streamParser } from '@pnpm/logger'
import { initDefaultReporter } from '@pnpm/cli.default-reporter'
const stopReporting = initDefaultReporter({
context: {
argv: [],
},
streamParser,
})
try {
// calling some pnpm APIs
} finally {
stopReporting()
}
pnpm-render bin
Installing this package exposes a pnpm-render bin that reads pnpm-shaped NDJSON from stdin and renders it through the default reporter. This lets external tools that emit pnpm:* log records reuse pnpm's renderer.
For example, pacquet emits the same wire format under --reporter=ndjson (to stderr), so its output can be piped through pnpm-render:
pacquet install --reporter=ndjson 2>&1 >/dev/null | pnpm-render
The redirect (2>&1 >/dev/null) is needed because pacquet writes the NDJSON stream to stderr.
An optional first positional argument sets the command name (defaults to install); pass it to match the verb the producer is running so command-specific renderers behave correctly:
pacquet add lodash --reporter=ndjson 2>&1 >/dev/null | pnpm-render add
Style Guide
- Never use blue or grey as font color as they are hard to read in many consoles.
- Use dim instead of grey
- Use cyan bright instead of blue
- Don't hide the CLI cursor. (It is easier to never hide but it is really needed only when scripts are running.)
- Don't use green and yellow to distinct something.