Skip to content

Commit

Permalink
Add color on phpcsfixer
Browse files Browse the repository at this point in the history
  • Loading branch information
oallain committed Jul 9, 2022
1 parent 3ec61c1 commit 295014c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/Task/PhpCsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ public function run(ContextInterface $context): TaskResultInterface
$this->formatter->resetCounter();

$arguments = $this->processBuilder->createArgumentsForCommand('php-cs-fixer');
$arguments->add('--format=json');
$arguments->add('--format=txt');
$arguments->add('--dry-run');
$arguments->addOptionalBooleanArgument('--allow-risky=%s', $config['allow_risky'], 'yes', 'no');
$arguments->addOptionalArgument('--cache-file=%s', $config['cache_file']);
$arguments->addOptionalArgument('--config=%s', $config['config']);
$arguments->addOptionalArgument('--ansi', true);

if ($rules = $config['rules']) {
$arguments->add(sprintf(
Expand Down
39 changes: 26 additions & 13 deletions test/Unit/Task/PhpCsFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--verbose',
'fix',
]
Expand All @@ -128,9 +129,10 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--allow-risky=yes',
'--ansi',
'--verbose',
'fix',
]
Expand All @@ -142,9 +144,10 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--cache-file=cachefile',
'--ansi',
'--verbose',
'fix',
]
Expand All @@ -156,9 +159,10 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--config=config.php',
'--ansi',
'--verbose',
'fix',
]
Expand All @@ -170,8 +174,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--rules=foo,bar',
'--verbose',
'fix',
Expand All @@ -188,8 +193,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--rules='.json_encode($rules),
'--verbose',
'fix',
Expand All @@ -202,8 +208,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--using-cache=yes',
'--verbose',
'fix',
Expand All @@ -216,8 +223,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'fix',
]
];
Expand All @@ -228,8 +236,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--verbose',
'--diff',
'fix',
Expand All @@ -242,8 +251,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--verbose',
'fix',
]
Expand All @@ -255,8 +265,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--verbose',
'fix',
'hello.php',
Expand All @@ -270,8 +281,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(GitPreCommitContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--verbose',
'fix',
'hello.php',
Expand All @@ -285,8 +297,9 @@ public function provideExternalTaskRuns(): iterable
$this->mockContext(GitPreCommitContext::class, ['hello.php', 'hello2.php']),
'php-cs-fixer',
[
'--format=json',
'--format=txt',
'--dry-run',
'--ansi',
'--path-mode=intersection',
'--verbose',
'fix',
Expand Down

0 comments on commit 295014c

Please sign in to comment.