Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
```
5 changes: 4 additions & 1 deletion src/Command/Site/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ private function addUpdateCommand() {
'command' => 'site:update',
'arguments' => array(
'name' => $this->siteName,
)
),
'options' => array(
'skip' => implode(',', $this->skip),
),
);
}

Expand Down
30 changes: 27 additions & 3 deletions src/Command/Site/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +22,11 @@
*/
class UpdateCommand extends AbstractCommand {

/**
* @var $skip.
* List of commands to skip
*/
private $skip;

/**
* {@inheritdoc}
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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);
Expand Down