Skip to content

Commit

Permalink
Merge pull request #127 from vkryklyvenko/patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue authored Jun 8, 2022
2 parents b395e50 + 3798119 commit 0ca09a8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ protected function configure(): void
'q',
InputOption::VALUE_NONE,
'Allow to silently fail.'
)
->addOption(
'no-files-exit-code',
'nf',
InputOption::VALUE_NONE,
'Throw error if no files processed.'
);
}

Expand Down Expand Up @@ -153,19 +159,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$fileCount = count($linter->getFiles());
$code = 0;

if ($fileCount <= 0) {
$output->writeln('<info>Could not find files to lint</info>');

return 0;
if (!empty($options['no-files-exit-code'])) {
$code = 1;
}

return $code;
}

$errors = $this->executeLint($linter, $input, $output, $fileCount);

$timeUsage = Helper::formatTime(microtime(true) - $startTime);
$memUsage = Helper::formatMemory(memory_get_usage(true) - $startMemUsage);

$code = 0;
$errCount = count($errors);

$output->writeln(sprintf(
Expand Down

0 comments on commit 0ca09a8

Please sign in to comment.