Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #248: Display error message on faulty composer.json #263

Merged
merged 1 commit into from Jan 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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