Skip to content

Commit 7f449c4

Browse files
committed
Add an ignore-debug option for code-style:check
1 parent bdc1052 commit 7f449c4

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/Phug/DevTool/Command/CheckCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ class CheckCommand extends AbstractCommand
1212
protected function configure()
1313
{
1414
$this->setName('check')
15-
->addOption('report', null, InputOption::VALUE_NONE)
15+
->addOption('report', null, InputOption::VALUE_NONE, 'Send coverage report?')
1616
->addOption('coverage-text', null, InputOption::VALUE_NONE, 'Display coverage info?')
1717
->addOption('coverage-html', null, InputOption::VALUE_OPTIONAL, 'Save coverage info as HTML?', false)
1818
->addOption('coverage-clover', null, InputOption::VALUE_OPTIONAL, 'Save coverage info as XML?', false)
1919
->addOption('group', null, InputOption::VALUE_OPTIONAL, 'Excute only a tests group?', false)
20-
->addOption('ignore-tests', null, InputOption::VALUE_NONE)
20+
->addOption('ignore-tests', null, InputOption::VALUE_NONE, 'Ignore /tests/ directories')
21+
->addOption('ignore-debug', null, InputOption::VALUE_NONE, 'Ignore /debug/ directories')
2122
->setDescription('Runs all necessary checks.')
2223
->setHelp('Runs all necessary checks');
2324
}

src/Phug/DevTool/Command/CodeStyleCheckCommand.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class CodeStyleCheckCommand extends AbstractCommand
1313
protected function configure()
1414
{
1515
$this->setName('code-style:check')
16-
->addOption('ignore-tests', null, InputOption::VALUE_NONE)
16+
->addOption('ignore-tests', null, InputOption::VALUE_NONE, 'Ignore /tests/ directories')
17+
->addOption('ignore-debug', null, InputOption::VALUE_NONE, 'Ignore /debug/ directories')
1718
->setDescription('Runs code style checker (phpcs).')
1819
->setHelp('This command runs the code style checker');
1920
}
@@ -24,8 +25,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
2425
$args = [
2526
'--standard' => $this->getApplication()->getConfigFilePath('phpcs.xml'),
2627
];
28+
$ignore = [];
2729
if ($input->getOption('ignore-tests')) {
28-
$args[] = '--ignore=*/tests/*';
30+
$ignore[] = '*/tests/*';
31+
}
32+
if ($input->getOption('ignore-debug')) {
33+
$ignore[] = '*/debug/*';
34+
}
35+
if (count($ignore)) {
36+
$args[] = '--ignore='.implode(',', $ignore);
2937
}
3038

3139
if (($code = $this->getApplication()->runCodeStyleChecker($args)) === 0) {

tests/Phug/DevTool/Command/CodeStyleCheckCommandTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,17 @@ public function testExecute()
4040

4141
self::assertSame(0, $code);
4242
self::assertRegExp('/Code looks great\. Go on!/', $buffer->fetch());
43+
44+
$cwd = getcwd();
45+
chdir(__DIR__.'/../../../app');
46+
$input = new StringInput('code-style:check --ignore-debug --ignore-tests');
47+
$buffer = new BufferedOutput();
48+
$app = new Application();
49+
$app->setAutoExit(false);
50+
$code = $app->run($input, $buffer);
51+
chdir($cwd);
52+
53+
self::assertSame(0, $code);
54+
self::assertRegExp('/Code looks great\. Go on!/', $buffer->fetch());
4355
}
4456
}

0 commit comments

Comments
 (0)