From 2ebc795754896a379d0011d9837be78002435f1a Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 2 Oct 2011 21:24:09 +0200 Subject: [PATCH] Error out when a package can not be found, refs #30 --- src/Composer/Command/InstallCommand.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 799d4acb7..cf0c56018 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -76,8 +76,29 @@ EOT $policy = new DependencyResolver\DefaultPolicy(); $solver = new DependencyResolver\Solver($policy, $pool, $localRepo); - // solve dependencies and execute operations - foreach ($solver->solve($request) as $operation) { + // solve dependencies + $operations = $solver->solve($request); + + // check for missing deps + // TODO this belongs in the solver, but this will do for now to report top-level deps missing at least + foreach ($request->getJobs() as $job) { + if ('install' === $job['cmd']) { + foreach ($localRepo->getPackages() as $package) { + if ($job['packageName'] === $package->getName()) { + continue 2; + } + } + foreach ($operations as $operation) { + if ('install' === $operation->getJobType() && $job['packageName'] === $operation->getPackage()->getName()) { + continue 2; + } + } + throw new \UnexpectedValueException('Package '.$job['packageName'].' could not be resolved to an installable package.'); + } + } + + // execute operations + foreach ($operations as $operation) { $installationManager->execute($operation); }