Skip to content

Instantly share code, notes, and snippets.

@yookoala
Created June 14, 2024 10:30
Show Gist options
  • Save yookoala/89f02aefc0b49789a7f4d42ebe533e57 to your computer and use it in GitHub Desktop.
Save yookoala/89f02aefc0b49789a7f4d42ebe533e57 to your computer and use it in GitHub Desktop.
A replacement bash function for the old drush launcher
#!/bin/bash
#
# Drush launcher no longer works in Druapl 10 because of
# the TTY check in the new Symfony's Process implementation.
#
# This script search for a "vendor/bin/drush" in the current
# folder herichey and proxy parameters to that drush. Feels
# like old launcher behaviour.
#
__find_vendor_drush() {
local dir="$PWD"
while [[ "$dir" != "/" ]]; do
if [[ -d "$dir/vendor" ]] && [[ -f "$dir/vendor/bin/drush" ]]; then
echo "$dir"
return 0
fi
dir=$(dirname "$dir")
done
if [[ -d "/vendor" && -f "/vendor/bin/drush" ]]; then
echo "/"
return 0
fi
return 1
}
drush() {
local dir
if dir=$(__find_vendor_drush); then
"$dir/vendor/bin/drush" $@
else
echo -e "\e[31mdrush not found in the current folder structure\e[0m"
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment