diff --git a/README.md b/README.md index 7eb3073..805771f 100644 --- a/README.md +++ b/README.md @@ -248,7 +248,8 @@ Each environment will have its own chain that executes the relevant commands and - **-h** - Shows all the available arguments and options. - **--no-interaction** - Executes the command without asking any optional argument -- **--skip** - Skips the execution of one or more commands (only `site:build`). +- **--learning**, **-vvv** - Verbose messages +- **--skip** - Skips the execution of one or more commands (only `site:build`, `site:update`). ## Environment variables @@ -264,6 +265,6 @@ For example, to override the root directory you can set the variable before call drupal site:build drupal site:build d7-example drupal site:build d7-example -e dev --branch="master" -drupal site:build d7-example -e dev --branch="master" --skip="checkout, compose" +drupal site:build d7-example -e dev --branch="master" --skip="checkout, compose, config:import" drupal site:db:import d7-example ``` diff --git a/src/Command/Site/BuildCommand.php b/src/Command/Site/BuildCommand.php index bd4977f..47f0dd9 100644 --- a/src/Command/Site/BuildCommand.php +++ b/src/Command/Site/BuildCommand.php @@ -374,7 +374,10 @@ private function addUpdateCommand() { 'command' => 'site:update', 'arguments' => array( 'name' => $this->siteName, - ) + ), + 'options' => array( + 'skip' => implode(',', $this->skip), + ), ); } diff --git a/src/Command/Site/UpdateCommand.php b/src/Command/Site/UpdateCommand.php index bd1f4ca..a365ac3 100644 --- a/src/Command/Site/UpdateCommand.php +++ b/src/Command/Site/UpdateCommand.php @@ -9,6 +9,8 @@ namespace DennisDigital\Drupal\Console\Command\Site; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use DennisDigital\Drupal\Console\Command\Exception\CommandException; @@ -20,6 +22,11 @@ */ class UpdateCommand extends AbstractCommand { + /** + * @var $skip. + * List of commands to skip + */ + private $skip; /** * {@inheritdoc} @@ -30,11 +37,27 @@ protected function configure() { $this->setName('site:update') ->setDescription('Update.'); + $this->addOption( + 'skip', + '', + InputOption::VALUE_OPTIONAL, + 'Used to skip one or more commands. i.e. --skip="config:import"' + ); } protected function interact(InputInterface $input, OutputInterface $output) { parent::interact($input, $output); + $this->input = $input; + $this->output = $output; + $this->inputOptions = array_filter($input->getOptions()); + + $this->skip = array(); + if (isset($this->inputOptions['skip'])) { + $this->skip = explode(',', $this->inputOptions['skip']); + } + // Trim input. + $this->skip = array_map('trim', $this->skip); } /** @@ -66,10 +89,11 @@ protected function execute(InputInterface $input, OutputInterface $output) { $commands[] = 'drupal update:execute'; $this->addModuleEnableCommands($commands); $this->addModuleDisableCommands($commands); - if ($this->fileExists($this->getWebRoot() . $this->getConfigUrl() . '/system.site.yml')) { - $commands[] = 'drupal config:import'; + if (!in_array('config:import', $this->skip)) { + if ($this->fileExists($this->getWebRoot() . $this->getConfigUrl() . '/system.site.yml')) { + $commands[] = 'drupal config:import'; + } } - //$commands[] = 'drupal cache:rebuild all'; } $command = implode(' ; ', $commands);