Skip to content

Commit 7415d8d

Browse files
committed
fix exit code
1 parent 8a8b392 commit 7415d8d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Console/ConsoleApplication.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Input\InputOption;
1818
use Symfony\Component\Console\Output\OutputInterface;
19+
use Symfony\Component\Console\Style\SymfonyStyle;
1920
use Webmozart\Assert\Assert;
2021

2122
final class ConsoleApplication extends Application
@@ -42,7 +43,7 @@ final class ConsoleApplication extends Application
4243
/**
4344
* @param Command[] $commands
4445
*/
45-
public function __construct(array $commands)
46+
public function __construct(array $commands, private readonly SymfonyStyle $symfonyStyle)
4647
{
4748
parent::__construct(self::NAME, VersionResolver::PACKAGE_VERSION);
4849

@@ -91,7 +92,15 @@ public function doRun(InputInterface $input, OutputInterface $output): int
9192
$tokens = array_merge(['process'], $tokens);
9293
$privatesAccessor->setPrivateProperty($input, 'tokens', $tokens);
9394
} elseif (! in_array($commandName, self::ALLOWED_COMMANDS, true)) {
94-
Assert::fileExists($commandName);
95+
$this->symfonyStyle->error(
96+
sprintf(
97+
'The following given path does not match any files or directories: %s%s',
98+
"\n\n - ",
99+
$commandName
100+
)
101+
);
102+
103+
return ExitCode::FAILURE;
95104
}
96105

97106
return parent::doRun($input, $output);

0 commit comments

Comments
 (0)