Merge remote-tracking branch 'Soullivaneuh/depends-match-constraint'
commit
9e42eedf1f
|
@ -20,6 +20,7 @@ use Composer\Repository\CompositeRepository;
|
|||
use Composer\Repository\PlatformRepository;
|
||||
use Composer\Plugin\CommandEvent;
|
||||
use Composer\Plugin\PluginEvents;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
@ -44,6 +45,8 @@ class DependsCommand extends Command
|
|||
->setDefinition(array(
|
||||
new InputArgument('package', InputArgument::REQUIRED, 'Package to inspect'),
|
||||
new InputOption('link-type', '', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Link types to show (require, require-dev)', array_keys($this->linkTypes)),
|
||||
new InputOption('match-constraint', '', InputOption::VALUE_REQUIRED, 'Constraint to match', '*'),
|
||||
new InputOption('match-constraint-invert', '', InputOption::VALUE_NONE, 'If constraint match should be inverted'),
|
||||
))
|
||||
->setHelp(<<<EOT
|
||||
Displays detailed information about where a package is referenced.
|
||||
|
@ -89,6 +92,10 @@ EOT
|
|||
return $type;
|
||||
}, $input->getOption('link-type'));
|
||||
|
||||
$versionParser = new VersionParser();
|
||||
$constraint = $versionParser->parseConstraints($input->getOption('match-constraint'));
|
||||
$matchInvert = $input->getOption('match-constraint-invert');
|
||||
|
||||
$messages = array();
|
||||
$outputPackages = array();
|
||||
$io = $this->getIO();
|
||||
|
@ -97,7 +104,7 @@ EOT
|
|||
foreach ($types as $type) {
|
||||
/** @var Link $link */
|
||||
foreach ($package->{'get'.$linkTypes[$type][0]}() as $link) {
|
||||
if ($link->getTarget() === $needle) {
|
||||
if ($link->getTarget() === $needle && ($link->getConstraint()->matches($constraint) ? !$matchInvert : $matchInvert)) {
|
||||
if (!isset($outputPackages[$package->getName()])) {
|
||||
$messages[] = '<info>'.$package->getPrettyName() . '</info> ' . $linkTypes[$type][1] . ' ' . $needle .' (<info>' . $link->getPrettyConstraint() . '</info>)';
|
||||
$outputPackages[$package->getName()] = true;
|
||||
|
|
Loading…
Reference in New Issue