fix(cli): avoid truncated output on macOS #503
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use console.log() instead of process.stdout.write() will avoid potential output truncation on macOS.
Description
Replace usage of
process.stdout.write()
withconsole.log()
.Motivation and Context
I noticed this first when using
commitlint
withhusky
:I confirmed this wasn't a
husky
-specific issue by simply piping STDIN: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
: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":
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
Checklist: