Repository navigation
Route ConsoleChannel errors to stderr through an OutputStyle - #27
Merged
Merged
Conversation
A command's output is an OutputStyle, which is not a ConsoleOutputInterface, so error-level lines handed a command's output went to stdout. Unwrap the style first, a local copy of laranail/console's ErrorOutput::unwrap() since this module has no laranail dependency, and declare illuminate/console for OutputStyle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When
ConsoleChannel::send()gets an error-level message, it routes it to stderr only if$output instanceof ConsoleOutputInterface. A command's$this->outputis anOutputStyle.Illuminate\Console\Command::run()wraps the terminal output in one, and anOutputStyleis not aConsoleOutputInterface, so injecting a command's output sent error lines to stdout. Nothing in the package passes anOutputStyletoday, so the defect is latent. It is the same defect laranail/console fixed in #77 and in laranail/console#82.laranail/console'sErrorOutput::unwrap(), with a docblock that points at it. This module deliberately carries nolaranail/*dependency.requirenow namesilluminate/console, forOutputStyle.laravel/frameworkalready replaces it, so nothing new is installed.DeclaredRequirementsTestfails without this line; I checked that locally.[Unreleased]: a Fixed entry.Tests
tests/Unit/ConsoleChannelStreamTest.phpuses a split stdout/stderrConsoleOutputInterfacestand-in:OutputStylereaches stderr;OutputStylestays on stdout;Fail-first: on the old code the
OutputStyleerror case fails (stdout was not empty) and the other two pass.Local: pest 81 passed, phpstan clean, rector clean, phpcs 0 errors. Pint is clean against package-tools'
pint.json; the localpint.jsonis byte-identical to it.