diff --git a/src/Command/RectorCommand.php b/src/Command/RectorCommand.php index 9ec3a8d6..2098f1b9 100644 --- a/src/Command/RectorCommand.php +++ b/src/Command/RectorCommand.php @@ -83,10 +83,11 @@ protected function runRector(ConsoleIo $io, Arguments $args, string $autoload): $cmdPath = ROOT . '/vendor/bin/rector process'; $command = sprintf( - '%s %s %s --autoload-file=%s --config=%s %s --clear-cache', + '%s %s %s %s --autoload-file=%s --config=%s %s --clear-cache', $cmdPath, $args->getOption('dry-run') ? '--dry-run' : '', $args->getOption('verbose') ? '--debug' : '', + $args->getOption('no-diff') ? '--no-diff' : '', escapeshellarg($autoload), escapeshellarg($config), escapeshellarg($path), @@ -199,6 +200,10 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption ->addOption('dry-run', [ 'help' => 'Enable to get a preview of what modifications will be applied.', 'boolean' => true, + ]) + ->addOption('no-diff', [ + 'help' => 'Disable rector diff output which can cause issues with large files.', + 'boolean' => true, ]); return $parser; diff --git a/tests/TestCase/Command/RectorCommandTest.php b/tests/TestCase/Command/RectorCommandTest.php index 6925df2c..97bbb9d4 100644 --- a/tests/TestCase/Command/RectorCommandTest.php +++ b/tests/TestCase/Command/RectorCommandTest.php @@ -68,6 +68,16 @@ public function testApplyAppDir() $this->assertOutputContains('Rector applied successfully'); } + public function testApplyNoDiff() + { + $this->setupTestApp(__FUNCTION__); + $this->exec('upgrade rector --rules cakephp40 --dry-run --no-diff ' . TEST_APP); + + $this->assertExitSuccess(); + $this->assertOutputNotContains('begin diff'); + $this->assertOutputContains('Rector applied successfully'); + } + /** * @return void */