feat: no longer use wrapped process.stdout and process.stderr #832
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.
When a spinner is started, it creates a mock version of
process.stdout.write
andprocess.stderr.write
to capture all log messages (fromconsole.log
,debug
,ux.log
, etc...) and then flushes the captured logs just before re-rendering the spinner.By encapsulating
process.stdout
andprocess.stderr
(introduced here), the spinner was no longer able to capture all logs messages - just the ones that went through the encapsulatedprocess.stdout
andprocess.stderr
. This means that anything sent to the terminal viaconsole.log
ordebug
was at risk of being overwritten when the spinner re-render.The solution here is to back out of using the encapsulated
process.stdout
andprocess.stderr
. These were originally added so that it would be easier to stubprocess.stdout|stderr.write
in unit tests (see mocha issue related to stubbingprocess.stdout.write
). In place of that, I've reduced the usage ofprocess.stdout.write
towrite.stdout
andwrite.stderr
and addedmakeStubs
method toux
that people can use if they need to stub those.I've also deprecated the
Stream
class that was used to encapsulateprocess.stdout
andprocess.stderr
and will be removed in the next major versionFixes #799
Closes #828
(Passing tests depend on #836)