diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 365733d85..aed62b1a2 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -40,11 +40,11 @@ abstract class BaseCommand extends Command /** * @param bool $required - * @param bool $disablePlugins + * @param bool|null $disablePlugins * @throws \RuntimeException * @return Composer */ - public function getComposer($required = true, $disablePlugins = false) + public function getComposer($required = true, $disablePlugins = null) { if (null === $this->composer) { $application = $this->getApplication(); diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 847639e7f..430f7816c 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -58,6 +58,7 @@ class Application extends BaseApplication '; private $hasPluginCommands = false; + private $disablePluginsByDefault = false; public function __construct() { @@ -108,6 +109,8 @@ class Application extends BaseApplication */ public function doRun(InputInterface $input, OutputInterface $output) { + $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins'); + $io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); ErrorHandler::register($io); @@ -127,7 +130,7 @@ class Application extends BaseApplication } } - if (!$input->hasParameterOption('--no-plugins') && !$this->hasPluginCommands && 'global' !== $commandName) { + if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) { try { foreach ($this->getPluginCommands() as $command) { if ($this->has($command->getName())) { @@ -300,12 +303,16 @@ class Application extends BaseApplication /** * @param bool $required - * @param bool $disablePlugins + * @param bool|null $disablePlugins * @throws JsonValidationException * @return \Composer\Composer */ - public function getComposer($required = true, $disablePlugins = false) + public function getComposer($required = true, $disablePlugins = null) { + if (null === $disablePlugins) { + $disablePlugins = $this->disablePluginsByDefault; + } + if (null === $this->composer) { try { $this->composer = Factory::create($this->io, null, $disablePlugins);