Skip to content

Commit 85e5ccc

Browse files
committed
Fix with check format on worker as well
1 parent 33d9f9a commit 85e5ccc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

e2e/applied-no-diffs-format-json/expected-output.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
},
66
"changed_files": [
77
"src/RemoveAlwaysElse.php"
8-
],
8+
]
99
}

src/Console/Command/WorkerCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Rector\Autoloading\AdditionalAutoloader;
1414
use Rector\Configuration\ConfigurationFactory;
1515
use Rector\Configuration\ConfigurationRuleFilter;
16+
use Rector\Configuration\Option;
1617
use Rector\Console\ProcessConfigureDecorator;
1718
use Rector\Parallel\ValueObject\Bridge;
1819
use Rector\StaticReflection\DynamicSourceLocatorDecorator;
@@ -75,6 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7576
$promise->then(function (ConnectionInterface $connection) use (
7677
$parallelIdentifier,
7778
$configuration,
79+
$input,
7880
$output
7981
): void {
8082
$inDecoder = new Decoder($connection, true, 512, JSON_INVALID_UTF8_IGNORE);
@@ -85,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8587
ReactCommand::IDENTIFIER => $parallelIdentifier,
8688
]);
8789

88-
$this->runWorker($outEncoder, $inDecoder, $configuration, $output);
90+
$this->runWorker($outEncoder, $inDecoder, $configuration, $input, $output);
8991
});
9092

9193
$streamSelectLoop->run();
@@ -97,6 +99,7 @@ private function runWorker(
9799
Encoder $encoder,
98100
Decoder $decoder,
99101
Configuration $configuration,
102+
InputInterface $input,
100103
OutputInterface $output
101104
): void {
102105
$this->additionalAutoloader->autoloadPaths();
@@ -128,7 +131,7 @@ private function runWorker(
128131
$encoder->on(ReactEvent::ERROR, $handleErrorCallback);
129132

130133
// 2. collect diffs + errors from file processor
131-
$decoder->on(ReactEvent::DATA, function (array $json) use ($preFileCallback, $encoder, $configuration): void {
134+
$decoder->on(ReactEvent::DATA, function (array $json) use ($preFileCallback, $encoder, $configuration, $input): void {
132135
$action = $json[ReactCommand::ACTION];
133136
if ($action !== Action::MAIN) {
134137
return;
@@ -151,7 +154,7 @@ private function runWorker(
151154
$encoder->write([
152155
ReactCommand::ACTION => Action::RESULT,
153156
self::RESULT => [
154-
Bridge::FILE_DIFFS => $processResult->getFileDiffs(),
157+
Bridge::FILE_DIFFS => $processResult->getFileDiffs($input->getOption(Option::OUTPUT_FORMAT) !== 'json'),
155158
Bridge::FILES_COUNT => count($filePaths),
156159
Bridge::SYSTEM_ERRORS => $processResult->getSystemErrors(),
157160
Bridge::SYSTEM_ERRORS_COUNT => count($processResult->getSystemErrors()),

0 commit comments

Comments
 (0)