Skip to content

Commit

Permalink
fix: require stdout to be a TTY for progress (#7507)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored May 11, 2024
1 parent 8add914 commit e3721c2
Show file tree
Hide file tree
Showing 2 changed files with 6 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
1 change: 1 addition & 0 deletions workspaces/config/test/definitions/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ t.test('color', t => {
t.test('progress', t => {
const setEnv = ({ tty, term } = {}) => mockGlobals(t, {
'process.stderr.isTTY': tty,
'process.stdout.isTTY': tty,
'process.env.TERM': term,
})

Expand Down

0 comments on commit e3721c2

Please sign in to comment.