add isProxyCommand() to BaseCommand
parent
d07b4e0f3e
commit
92207da83a
|
@ -79,6 +79,18 @@ abstract class BaseCommand extends Command
|
|||
$this->getApplication()->resetComposer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not this command is meant to call another command.
|
||||
*
|
||||
* This is mainly needed to avoid duplicated warnings messages.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isProxyCommand()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IOInterface
|
||||
*/
|
||||
|
|
|
@ -80,4 +80,12 @@ EOT
|
|||
|
||||
return $this->getApplication()->run($input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isProxyCommand()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,4 +71,12 @@ EOT
|
|||
|
||||
return $this->getApplication()->run($input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isProxyCommand()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ class Application extends BaseApplication
|
|||
/_/
|
||||
';
|
||||
|
||||
private $hasPluginCommands = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
static $shutdownRegistered = false;
|
||||
|
@ -107,17 +109,29 @@ class Application extends BaseApplication
|
|||
$io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
|
||||
ErrorHandler::register($io);
|
||||
|
||||
// determine command name to be executed
|
||||
if (!$input->hasParameterOption('--no-plugins') && !$this->hasPluginCommands) {
|
||||
foreach ($this->getPluginCommands() as $command) {
|
||||
if ($this->has($command->getName())) {
|
||||
$io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
|
||||
} else {
|
||||
$this->add($command);
|
||||
}
|
||||
}
|
||||
$this->hasPluginCommands = true;
|
||||
}
|
||||
|
||||
// determine command name to be executed, and if it's a proxy command
|
||||
$commandName = '';
|
||||
$isProxyCommand = false;
|
||||
if ($name = $this->getCommandName($input)) {
|
||||
try {
|
||||
$commandName = $this->find($name)->getName();
|
||||
$command = $this->find($name);
|
||||
$commandName = $command->getName();
|
||||
$isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
$isProxyCommand = $commandName === 'global' || $commandName === 'outdated';
|
||||
|
||||
if (!$isProxyCommand) {
|
||||
$io->writeError(sprintf(
|
||||
'Running %s (%s) with %s on %s',
|
||||
|
@ -196,16 +210,6 @@ class Application extends BaseApplication
|
|||
$this->io->enableDebugging($startTime);
|
||||
}
|
||||
|
||||
if (!$input->hasParameterOption('--no-plugins') && !$isProxyCommand) {
|
||||
foreach ($this->getPluginCommands() as $command) {
|
||||
if ($this->has($command->getName())) {
|
||||
$io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
|
||||
} else {
|
||||
$this->add($command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$result = parent::doRun($input, $output);
|
||||
|
||||
if (isset($oldWorkingDir)) {
|
||||
|
|
|
@ -25,6 +25,11 @@ class ApplicationTest extends TestCase
|
|||
$inputMock = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||
$outputMock = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||
|
||||
$inputMock->expects($this->once())
|
||||
->method('hasParameterOption')
|
||||
->with($this->equalTo('--no-plugins'))
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$inputMock->expects($this->once())
|
||||
->method('getFirstArgument')
|
||||
->will($this->returnValue('list'));
|
||||
|
|
Loading…
Reference in New Issue