From 301542d77f860025131d3949d83ef6c85ad5f754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Tue, 4 Jan 2022 16:30:13 +0100 Subject: [PATCH] Resolve #248: Display error message on faulty composer.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Frömer --- src/Console/Command/UnusedCommand.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Console/Command/UnusedCommand.php b/src/Console/Command/UnusedCommand.php index 9b662081..01e1e735 100644 --- a/src/Console/Command/UnusedCommand.php +++ b/src/Console/Command/UnusedCommand.php @@ -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; } @@ -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) {