Skip to content

Commit

Permalink
Resolve #248: Display error message on faulty composer.json
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Frömer <andreas.froemer@check24.de>
  • Loading branch information
Andreas Frömer authored and icanhazstring committed Jan 4, 2022
1 parent 8da70a4 commit 40f69d7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Console/Command/UnusedCommand.php
Expand Up @@ -97,15 +97,24 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$composerJsonPath = $input->getArgument('composer-json');

if (!file_exists($composerJsonPath) && !is_readable($composerJsonPath)) {
$io->error(
sprintf(
'composer.json on given path %s does not exist or is not readable.',
$composerJsonPath
)
);

return 1;
}

$composerJson = file_get_contents($composerJsonPath);

if ($composerJson === false) {
$io->error('Unable to read contents from given composer.json');
return 1;
}

Expand Down Expand Up @@ -138,8 +147,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
)
);

$io = new SymfonyStyle($input, $output);

foreach ($consumedSymbols as $symbol) {
/** @var RequiredDependency $requiredDependency */
foreach ($requiredDependencyCollection as $requiredDependency) {
Expand Down

0 comments on commit 40f69d7

Please sign in to comment.