From 9dee60d9f9c80cb0bc898ede37c8e28f27595801 Mon Sep 17 00:00:00 2001 From: outermedia-sol Date: Thu, 19 Sep 2019 22:43:48 +0200 Subject: [PATCH 1/4] new parameter for drush from Vendor directory Added new Parameter -v to indicate to use Vendor parameter If -v is added as parameter /../vendor/drush/drush/drush is added to the path default for DRUSH is then /../vendor/drush/drush/drush Only problem: could not get it to run with --config param. There was an error while checking is_drupal_root_dir. Therefore I just moved that setting to after this check. `[preflight] Unable to parse at line 1 (near "/dev/null; then + if ! "${DRUSH}" -r "${1}" --uri="${2}" status | grep 'Drupal root' 1>/dev/null; then return 1 fi return 0 @@ -522,7 +522,7 @@ print_version() { # @output string The requirements. # @return integer 0 on success, 2 on fail check() { - if command -v drush > /dev/null 2>&1; then + if command -v {$DRUSH} > /dev/null 2>&1; then echo "[OK] drush found" return "$EXIT_ERR" else @@ -535,7 +535,7 @@ check() { # @output string The usage screen. # @return integer 0 print_usage() { - printf "Usage: %s -d [-n ] [-s ] [-u ] [-e ] [-w ] [-m ] [-i ] [-l ] [-r]\n" "${INFO_NAME}" + printf "Usage: %s -d [-n ] [-s ] [-u ] [-e ] [-w ] [-m ] [-i ] [-l ] [-r]\n [-v]\n" "${INFO_NAME}" printf "OR %s --check\n" "${INFO_NAME}" printf "OR %s --help\n" "${INFO_NAME}" printf "OR %s --version\n\n" "${INFO_NAME}" @@ -612,6 +612,9 @@ print_help() { printf " -r [optional] Filters all updates that are locked via drush.\n" printf " For general infos about locking run 'drush pm-updatestatus -h'\n\n" + printf " -v [optional] Use Vendor Drush instead of global drush.\n" + printf " default for /../vendor/drush/drush/drush '\n\n" + printf " --check Check for program requirements.\n" printf " --help Show this help\n" printf " --version Show version information.\n" @@ -648,7 +651,7 @@ fi ############################################################ # Do we have 'drush'? -if ! command -v drush > /dev/null 2>&1 ; then +if ! command -v ${DRUSH} > /dev/null 2>&1 ; then printf "[UNKNOWN] 'drush' not found.\n" exit $EXIT_UNKNOWN fi @@ -769,6 +772,11 @@ while test -n "$1"; do -r) LOCK="1" ;; + -v) + VENDOR_DRUSH="1" + VENDOR_DRUSH_PATH="../vendor/drush/drush/drush" + DRUSH="${DRUPAL_ROOT}/${VENDOR_DRUSH_PATH}" + ;; *) printf "Unknown argument: %s\n" "$1" print_usage @@ -778,15 +786,6 @@ while test -n "$1"; do shift done -# Use a drushrc.php file to set the language to english -if ! DRUSHRC="$(write_drushrc)"; then - printf "[UNKNOWN] Unable to create tmpfile\n" - exit $EXIT_UNKNOWN -fi - -DRUSH="${DRUSH} --config=${DRUSHRC}" - - ############################################################ # Validate arguments ############################################################ @@ -824,6 +823,16 @@ if [ -n "$LOGGING" ]; then fi +# Use a drushrc.php file to set the language to english +if ! DRUSHRC="$(write_drushrc)"; then + printf "[UNKNOWN] Unable to create tmpfile\n" + exit $EXIT_UNKNOWN +fi + +DRUSH="${DRUSH} --config=${DRUSHRC}" + + + ############################################################ # Go Go Go!!!! ############################################################ From 68317c5f146df765bfb29e8666a40c44d072d94c Mon Sep 17 00:00:00 2001 From: outermedia-sol Date: Thu, 19 Sep 2019 23:06:03 +0200 Subject: [PATCH 2/4] Fixed warnings from travis shellcheck --- bin/check_drupal | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/check_drupal b/bin/check_drupal index 6a42b24..e392761 100755 --- a/bin/check_drupal +++ b/bin/check_drupal @@ -38,7 +38,7 @@ fi #PHP_OPTS="-d intl.default_locale='en_US'" # Drush executeable -DRUSH="$(which drush 2>/dev/null)" +DRUSH="$(command -v drush 2>/dev/null)" @@ -522,7 +522,7 @@ print_version() { # @output string The requirements. # @return integer 0 on success, 2 on fail check() { - if command -v {$DRUSH} > /dev/null 2>&1; then + if command -v "{$DRUSH}" > /dev/null 2>&1; then echo "[OK] drush found" return "$EXIT_ERR" else @@ -651,7 +651,7 @@ fi ############################################################ # Do we have 'drush'? -if ! command -v ${DRUSH} > /dev/null 2>&1 ; then +if ! command -v "${DRUSH}" > /dev/null 2>&1 ; then printf "[UNKNOWN] 'drush' not found.\n" exit $EXIT_UNKNOWN fi @@ -773,7 +773,6 @@ while test -n "$1"; do LOCK="1" ;; -v) - VENDOR_DRUSH="1" VENDOR_DRUSH_PATH="../vendor/drush/drush/drush" DRUSH="${DRUPAL_ROOT}/${VENDOR_DRUSH_PATH}" ;; From e8a23786eefa466649f032c3370e887bc16c6ff2 Mon Sep 17 00:00:00 2001 From: outermedia-iho <55700060+outermedia-iho@users.noreply.github.com> Date: Mon, 23 Sep 2019 16:07:12 +0200 Subject: [PATCH 3/4] add check for vendor drush --- bin/check_drupal | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/bin/check_drupal b/bin/check_drupal index e392761..da720e9 100755 --- a/bin/check_drupal +++ b/bin/check_drupal @@ -522,7 +522,7 @@ print_version() { # @output string The requirements. # @return integer 0 on success, 2 on fail check() { - if command -v "{$DRUSH}" > /dev/null 2>&1; then + if command -v "$DRUSH" > /dev/null 2>&1; then echo "[OK] drush found" return "$EXIT_ERR" else @@ -616,6 +616,7 @@ print_help() { printf " default for /../vendor/drush/drush/drush '\n\n" printf " --check Check for program requirements.\n" + printf " --check_vendor Check for program requirements, when using vendor drush. The parameter -d is required. \n" printf " --help Show this help\n" printf " --version Show version information.\n" return 0 @@ -636,6 +637,23 @@ if [ "${1}" = "--check" ]; then check exit $EXIT_OK fi +if [ "${1}" = "--check_vendor" ]; then + while test -n "$1"; do + + case "$1" in + -d) + # Get next arg in list (Path) + shift + DRUPAL_ROOT="$1" + ;; + esac + shift + done + VENDOR_DRUSH_PATH="../vendor/drush/drush/drush" + DRUSH="${DRUPAL_ROOT}/${VENDOR_DRUSH_PATH}" + check + exit $EXIT_OK +fi if [ "${1}" = "--help" ]; then print_help exit $EXIT_OK @@ -646,16 +664,6 @@ if [ "${1}" = "--version" ]; then fi -############################################################ -# Check requirements -############################################################ - -# Do we have 'drush'? -if ! command -v "${DRUSH}" > /dev/null 2>&1 ; then - printf "[UNKNOWN] 'drush' not found.\n" - exit $EXIT_UNKNOWN -fi - ############################################################ # Internal Variables @@ -785,6 +793,18 @@ while test -n "$1"; do shift done + +############################################################ +# Check requirements +############################################################ + +# Do we have 'drush'? +if ! command -v "${DRUSH}" > /dev/null 2>&1 ; then + printf "[UNKNOWN] 'drush' not found.\n" + exit $EXIT_UNKNOWN +fi + + ############################################################ # Validate arguments ############################################################ @@ -1115,4 +1135,3 @@ fi # " vim: set ts=4: - From 51988e0fd15dd725e493456409d2a352236e74cb Mon Sep 17 00:00:00 2001 From: outermedia-sol Date: Mon, 23 Sep 2019 16:16:16 +0200 Subject: [PATCH 4/4] fix indentation. --- bin/check_drupal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/check_drupal b/bin/check_drupal index da720e9..e8dd1f3 100755 --- a/bin/check_drupal +++ b/bin/check_drupal @@ -650,7 +650,7 @@ if [ "${1}" = "--check_vendor" ]; then shift done VENDOR_DRUSH_PATH="../vendor/drush/drush/drush" - DRUSH="${DRUPAL_ROOT}/${VENDOR_DRUSH_PATH}" + DRUSH="${DRUPAL_ROOT}/${VENDOR_DRUSH_PATH}" check exit $EXIT_OK fi