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

Fixes progress display on non-color tty (#4647) #4697

Merged
merged 1 commit into from
Oct 12, 2017
Merged

Fixes progress display on non-color tty (#4647) #4697

merged 1 commit into from
Oct 12, 2017

Conversation

nwholloway
Copy link
Contributor

If the output does not support color, then each render of the progress bar is added to a single line, which wraps over multiple lines.

As a fallback, a simple carriage return is used to move to the start of the line, and space characters to clear the line.

Summary

This is a minor cosmetic output on the formatting of the progress output.

I came across the issue raised when looking for problems to address for Hacktoberfest.

Test plan

I verified by running yarn check to provide output with the progress bar under the following conditions:

  • Interactive use with color output.
  • Interactive use with terminal not supporting color output
  • Non-interactive use (output was piped)

The output from the 3 tests can be seen in the following screenshot.

image

This screenshot shows the non-color test with the active progress bar.

image

If the output does not support color, then each render of the progress
bar is added to a single line, which wraps over multiple lines.

As a fallback, a simple carriage return is used to move to the start of
the line, and space characters to clear the line.
@buildsize
Copy link

buildsize bot commented Oct 12, 2017

This change will increase the build size from 9.94 MB to 9.94 MB, an increase of 969 bytes (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 859.25 KB 859.34 KB 100 bytes (0%)
yarn-[version].js 3.78 MB 3.78 MB 360 bytes (0%)
yarn-legacy-[version].js 3.83 MB 3.83 MB 360 bytes (0%)
yarn-v[version].tar.gz 864.93 KB 865 KB 73 bytes (0%)
yarn_[version]all.deb 654 KB 654.07 KB 76 bytes (0%)

1 similar comment
@buildsize
Copy link

buildsize bot commented Oct 12, 2017

This change will increase the build size from 9.94 MB to 9.94 MB, an increase of 969 bytes (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 859.25 KB 859.34 KB 100 bytes (0%)
yarn-[version].js 3.78 MB 3.78 MB 360 bytes (0%)
yarn-legacy-[version].js 3.83 MB 3.83 MB 360 bytes (0%)
yarn-v[version].tar.gz 864.93 KB 865 KB 73 bytes (0%)
yarn_[version]all.deb 654 KB 654.07 KB 76 bytes (0%)

Copy link
Member

@arcanis arcanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@irfinnew
Copy link

Works for me (#4647 reporter here)!

@arcanis arcanis merged commit 4c38ca7 into yarnpkg:master Oct 12, 2017
@nwholloway nwholloway deleted the progress_bar branch October 12, 2017 15:39
@skevy
Copy link
Contributor

skevy commented Oct 16, 2017

@arcanis @nwholloway just updated to latest master with this commit in it.

Running on a mac in my CI:

RangeError: Invalid count value
  | at String.repeat (native)
  | at clearLine (/usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:45689:29)
  | at ConsoleReporter._log (/usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:84107:43)
  | at ConsoleReporter.log (/usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:84095:10)
  | at ConsoleReporter.header (/usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:84073:10)
  | at main (/usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:81411:14)
  | at /usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:81095:7
  | at Generator.next (<anonymous>)
  | at step (/usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:108:30)
  | at /usr/local/var/buildkite-agent/builds/mac-ci-2/exponent/dev-tools-xde-slash-xdl-slash-exp/master-c963080767f45828c31f83ca5cd25d36/tools/bin/yarn:126:14

Seems like stdout.columns might not always return what you expect?

This error is on macOS 10.12, Node 8.6.

skevy pushed a commit to expo/yarn that referenced this pull request Oct 16, 2017
@nwholloway
Copy link
Contributor Author

nwholloway commented Oct 16, 2017

I suspect that 'process.stdout.columns' is returning a negative number. I'm not sure why Node would believe it to be a tty, but not able to get the window size.

@skevy Would you like to try 0ef88f7 to see if this fixes the problem for you?

I would be interested in knowing what the job output in your CI environment looked like previous to my first change, and after this change.

skevy pushed a commit to expo/yarn that referenced this pull request Oct 25, 2017
joaolucasl pushed a commit to joaolucasl/yarn that referenced this pull request Oct 27, 2017
If the output does not support color, then each render of the progress
bar is added to a single line, which wraps over multiple lines.

As a fallback, a simple carriage return is used to move to the start of
the line, and space characters to clear the line.
BYK pushed a commit that referenced this pull request Oct 31, 2017
**Summary**

My recent pull request was to improve the appearance of the progress bar for non-color terminals (PR #4697).

However, @skevy reported a RangeError when running with macOS 10.12, with Node 8.6.  This would have been caused by process.stdout.columns returning a negative number.

In this case, this just assumes a default width of 100 characters (as in spinner-progress.js).

**Test plan**

I have not been able to reproduce the condition where `process.tty.columns` returns a negative number, so have verified the logic by considering key cases, e.g., `undefined > 0`, `-1 > 0`.
calvinhuang pushed a commit to calvinhuang/yarn that referenced this pull request Nov 9, 2017
**Summary**

My recent pull request was to improve the appearance of the progress bar for non-color terminals (PR yarnpkg#4697).

However, @skevy reported a RangeError when running with macOS 10.12, with Node 8.6.  This would have been caused by process.stdout.columns returning a negative number.

In this case, this just assumes a default width of 100 characters (as in spinner-progress.js).

**Test plan**

I have not been able to reproduce the condition where `process.tty.columns` returns a negative number, so have verified the logic by considering key cases, e.g., `undefined > 0`, `-1 > 0`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants