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(cli): avoid truncated output on macOS #503

Merged
merged 1 commit into from
Nov 30, 2018

Conversation

boneskull
Copy link
Contributor

Use console.log() instead of process.stdout.write() will avoid potential output truncation on macOS.

Description

Replace usage of process.stdout.write() with console.log().

Motivation and Context

I noticed this first when using commitlint with husky:

image

I confirmed this wasn't a husky-specific issue by simply piping STDIN:

image

On macOS, if output is truncated--the node process quits before the STDOUT stream has ended--we will see a %.

I then confirmed this happens in master:

image

I went and looked for the message in the codebase, and found it was output via a call to process.stdout.write(), which was the likely culprit.

How Has This Been Tested?

"Works on my machine":

image

I could write a test that asserts output isn't truncated, but I couldn't be sure that it wouldn't be flaky.

I couldn't find a reason why process.stdout.write() was used in the first place, which is the main risk with merging this. That said, it seems relatively safe to me. You be the judge.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Use console.log() instead of process.stdout.write() will avoid potential output truncation on macOS.
@byCedric
Copy link
Member

Great! I think I might have caused it when developing the ability to add custom formatters. The reason why I used process.stdout.write is mostly related to XO and ESLint "doing it too". To me, using a non-error/debug output for responses made sense. I guess I should have added at least a closing new line in there. Anyways, thanks for the detailed PR!

@marionebl marionebl merged commit 3192368 into conventional-changelog:master Nov 30, 2018
@marionebl
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants