5

Is there any way to check for differences with config in Drush 8?

I checked the list of drush 8 config commands and I couldn't find anything.

The reason I need this is that I have a site that runs behat tests via CircleCI, and sometimes I need to import the configuration more than once. So, I wanted to write a bash script that uses Drush to check whether there are any configuration differences, and if so, automatically re-imports the config in a loop until there are no more differences.

I'm stuck on Drush 8 because the behat extension only supports Drush 8.

1
  • 2
    You could probably pull in the config:status command from drush 9 into a module? Or use drush 8 globally, and drush 9 locally?
    – mradcliffe
    Jan 11 '19 at 13:16
5

The Drush 8 commands config:export (cex) and config:import (cim) accept a --no to prevent the actual import or export.

This allows you to write an if statement in Bash. Here is an example:

if drush config:import --no | grep file.settings; then 
  # Do something
  echo "Found in diff"; 
fi

In Drush 9 and 10, the return value $? will tell you if there are differences between the database and the directory containing YAML files:

  • 0 means no differences
  • 1 means differences

Drush 9 and 10 also accept a parameter --diff. If there are differences, Drush will print them.

3

If you have Drupal console installed, you could try config:diff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.