Skip to content

Commit 4ad4496

Browse files
authored
Add no-diff option (#360)
1 parent d9006df commit 4ad4496

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Command/RectorCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ protected function runRector(ConsoleIo $io, Arguments $args, string $autoload):
8383

8484
$cmdPath = ROOT . '/vendor/bin/rector process';
8585
$command = sprintf(
86-
'%s %s %s --autoload-file=%s --config=%s %s --clear-cache',
86+
'%s %s %s %s --autoload-file=%s --config=%s %s --clear-cache',
8787
$cmdPath,
8888
$args->getOption('dry-run') ? '--dry-run' : '',
8989
$args->getOption('verbose') ? '--debug' : '',
90+
$args->getOption('no-diff') ? '--no-diff' : '',
9091
escapeshellarg($autoload),
9192
escapeshellarg($config),
9293
escapeshellarg($path),
@@ -199,6 +200,10 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption
199200
->addOption('dry-run', [
200201
'help' => 'Enable to get a preview of what modifications will be applied.',
201202
'boolean' => true,
203+
])
204+
->addOption('no-diff', [
205+
'help' => 'Disable rector diff output which can cause issues with large files.',
206+
'boolean' => true,
202207
]);
203208

204209
return $parser;

tests/TestCase/Command/RectorCommandTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ public function testApplyAppDir()
6868
$this->assertOutputContains('Rector applied successfully');
6969
}
7070

71+
public function testApplyNoDiff()
72+
{
73+
$this->setupTestApp(__FUNCTION__);
74+
$this->exec('upgrade rector --rules cakephp40 --dry-run --no-diff ' . TEST_APP);
75+
76+
$this->assertExitSuccess();
77+
$this->assertOutputNotContains('begin diff');
78+
$this->assertOutputContains('Rector applied successfully');
79+
}
80+
7181
/**
7282
* @return void
7383
*/

0 commit comments

Comments
 (0)