Skip to content

Commit

Permalink
[1.x] Adds --bail flag (#261)
Browse files Browse the repository at this point in the history
* Adds `--bail` flag

* Update DefaultCommand.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
nunomaduro and taylorotwell authored Mar 20, 2024
1 parent fb4e240 commit 2f46ab4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Actions/ElaborateSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function execute($totalFiles, $changes)
0,
0,
$this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE,
$this->input->getOption('test'),
$this->input->getOption('test') || $this->input->getOption('bail'),
$this->output->isDecorated()
);

Expand Down
1 change: 1 addition & 0 deletions app/Commands/DefaultCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected function configure()
new InputOption('no-config', '', InputOption::VALUE_NONE, 'Disable loading any configuration file'),
new InputOption('preset', '', InputOption::VALUE_REQUIRED, 'The preset that should be used'),
new InputOption('test', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them'),
new InputOption('bail', '', InputOption::VALUE_NONE, 'Test for code style errors without fixing them and stop on first error'),
new InputOption('dirty', '', InputOption::VALUE_NONE, 'Only fix files that have uncommitted changes'),
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'The output format that should be used'),
new InputOption('cache-file', '', InputArgument::OPTIONAL, 'The path to the cache file'),
Expand Down
4 changes: 2 additions & 2 deletions app/Factories/ConfigurationResolverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function fromIO($input, $output)
sprintf('%s.php', $preset),
]),
'diff' => $output->isVerbose(),
'dry-run' => $input->getOption('test'),
'dry-run' => $input->getOption('test') || $input->getOption('bail'),
'path' => $path,
'path-mode' => ConfigurationResolver::PATH_MODE_OVERRIDE,
'cache-file' => $input->getOption('cache-file') ?? $localConfiguration->cacheFile() ?? implode(DIRECTORY_SEPARATOR, [
Expand All @@ -65,7 +65,7 @@ public static function fromIO($input, $output)
: (string) microtime()
),
]),
'stop-on-violation' => false,
'stop-on-violation' => $input->getOption('bail'),
'verbosity' => $output->getVerbosity(),
'show-progress' => 'true',
],
Expand Down
2 changes: 1 addition & 1 deletion app/Output/Concerns/InteractsWithSymbols.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getSymbol($status)
$statusSymbol = $this->statuses[$status];

if (! isset($statusSymbol['symbol'])) {
$statusSymbol = $this->input->getOption('test')
$statusSymbol = ($this->input->getOption('test') || $this->input->getOption('bail'))
? $statusSymbol[0]
: $statusSymbol[1];
}
Expand Down

0 comments on commit 2f46ab4

Please sign in to comment.