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

fix: require stdout to be a TTY for progress #7507

Merged
merged 2 commits into from
May 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading