From cf6a4801ca95d205732d33506456efdfe89be7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Dagef=C3=B6rde?= Date: Mon, 23 Oct 2017 21:18:50 +0200 Subject: [PATCH] Fix #65: Provide optional argument for `install` to skip DB installation --- src/Command/InstallCommand.php | 4 +++- src/Installer/InstallerFactory.php | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Command/InstallCommand.php b/src/Command/InstallCommand.php index de565f9..33ca5e7 100644 --- a/src/Command/InstallCommand.php +++ b/src/Command/InstallCommand.php @@ -90,7 +90,8 @@ protected function configure() ->addOption('db-host', null, InputOption::VALUE_REQUIRED, 'Database host', 'localhost') ->addOption('not-paths', null, InputOption::VALUE_REQUIRED, 'CSV of file paths to exclude', $paths) ->addOption('not-names', null, InputOption::VALUE_REQUIRED, 'CSV of file names to exclude', $names) - ->addOption('extra-plugins', null, InputOption::VALUE_REQUIRED, 'Directory of extra plugins to install', $extra); + ->addOption('extra-plugins', null, InputOption::VALUE_REQUIRED, 'Directory of extra plugins to install', $extra) + ->addOption('skip-db-install', null, InputOption::VALUE_REQUIRED, 'Skip DB installation, e.g. if only static analyses are required', false); } protected function initialize(InputInterface $input, OutputInterface $output) @@ -170,6 +171,7 @@ public function initializeInstallerFactory(InputInterface $input) $input->getOption('db-pass'), $input->getOption('db-host') ); + $factory->skipDbInstall = $input->getOption('skip-db-install'); return $factory; } diff --git a/src/Installer/InstallerFactory.php b/src/Installer/InstallerFactory.php index b536e2d..d72809e 100644 --- a/src/Installer/InstallerFactory.php +++ b/src/Installer/InstallerFactory.php @@ -71,6 +71,11 @@ class InstallerFactory */ public $pluginsDir; + /** + * @var bool + */ + public $skipDbInstall; + /** * Given a big bag of install options, add installers to the collection. * @@ -82,7 +87,9 @@ public function addInstallers(InstallerCollection $installers) $installers->add(new PluginInstaller($this->moodle, $this->plugin, $this->pluginsDir, $this->dumper)); $installers->add(new VendorInstaller($this->moodle, $this->plugin, $this->execute)); - if ($this->plugin->hasBehatFeatures() || $this->plugin->hasUnitTests()) { + if ($this->skipDbInstall) { + return; + } elseif ($this->plugin->hasBehatFeatures() || $this->plugin->hasUnitTests()) { $installers->add(new TestSuiteInstaller($this->moodle, $this->plugin, $this->execute)); } }