Skip to content

Commit

Permalink
#7 Add script to update grumphp.yml to add DDEV support.
Browse files Browse the repository at this point in the history
  • Loading branch information
hkirsman committed Feb 23, 2024
1 parent 81e5197 commit c70a482
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
32 changes: 32 additions & 0 deletions scripts/update-grumphp-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

#
# Script to update the grumphp.yml file to use both Lando and DDEV on GIT commit.
#
# It's run on composer install, only if grumphp.yml exists and if it contains:
# EXEC_GRUMPHP_COMMAND: lando php
# This is the previous default we've used.
#

set -eu
if [ -n "${WUNDERIO_DEBUG:-}" ]; then
set -x
fi
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/var/www/html/vendor/bin

# Path to the grumphp.yml file
config_file="grumphp.yml"

# Define the pattern to search for.
pattern="EXEC_GRUMPHP_COMMAND: lando php"

if [ -f "$config_file" ] && grep -q "$pattern" "$config_file"; then
sed -i "s#$pattern#EXEC_GRUMPHP_COMMAND: \"[ -d .ddev/traefik/ ] \&\& GRUMPHP_COMMAND='ddev php' || GRUMPHP_COMMAND='lando php' \&\& \$GRUMPHP_COMMAND\"#g" "$config_file"

# Add a message to the user.
color_red="\033[0;31m"
color_reset="\033[0m"
printf "${color_red}Added DDEV support to $config_file.\n"
echo "Please run \"ddev grumphp git:init\" for the changes to take affect."
printf "${color_reset}"
fi
5 changes: 3 additions & 2 deletions src/InstallHelperPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ public function onWunderIoDdevDrupalPackageInstall(PackageEvent $event) {

self::deployDdevFiles();

#$output = shell_exec('bash vendor/wunderio/lando-drupal/scripts/load_extensions.sh');
#$this->io->write("<info>{$output}</info>");
// Run the update-grumphp-command.php script.
$output = shell_exec('bash vendor/wunderio/ddev-drupal/scripts/update-grumphp-command.sh');
$this->io->write("<info>{$output}</info>");
}

/**
Expand Down

0 comments on commit c70a482

Please sign in to comment.