Skip to content

Commit

Permalink
fix: require stdout to be a TTY for progress
Browse files Browse the repository at this point in the history
Progress is shown on stderr but looks weird when stdout is piped to
another command. So we should only show it by default if both streams
are TTYs.
  • Loading branch information
lukekarrys committed May 10, 2024
1 parent 8add914 commit dd7958f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions workspaces/config/lib/definitions/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1549,13 +1549,16 @@ const definitions = {
type: Boolean,
description: `
When set to \`true\`, npm will display a progress bar during time
intensive operations, if \`process.stderr\` is a TTY.
intensive operations, if \`process.stderr\` and \`process.stdout\` are a TTY.
Set to \`false\` to suppress the progress bar.
`,
flatten (key, obj, flatOptions) {
flatOptions.progress = !obj.progress ? false
: !!process.stderr.isTTY && process.env.TERM !== 'dumb'
// progress is only written to stderr but we disable it unless stdout is a tty
// also. This prevents the progress from appearing when piping output to another
// command which doesn't break anything, but does look very odd to users.
: !!process.stderr.isTTY && !!process.stdout.isTTY && process.env.TERM !== 'dumb'
},
}),
provenance: new Definition('provenance', {
Expand Down

0 comments on commit dd7958f

Please sign in to comment.