From 4e255cd667008440168ef37f808d1cc036810b2f Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 31 Jul 2024 01:20:30 +0100 Subject: [PATCH] Ensure run.local files are located relative to the ...run file Prevent erroring if `run` is being executed within a sub-directory, like `assets`. --- templates/fractal/run.twig | 3 ++- templates/php/drupal/run.twig | 3 ++- templates/php/sculpin/run.twig | 3 ++- templates/terraform/run.twig | 3 ++- tests/snapshots/output/drupal-commerce-kickstart/run | 5 +++-- tests/snapshots/output/drupal-localgov/run | 5 +++-- tests/snapshots/output/drupal/run | 5 +++-- tests/snapshots/output/fractal/run | 3 ++- 8 files changed, 19 insertions(+), 11 deletions(-) diff --git a/templates/fractal/run.twig b/templates/fractal/run.twig index 7c240b4..48e55a8 100755 --- a/templates/fractal/run.twig +++ b/templates/fractal/run.twig @@ -119,7 +119,8 @@ function _run { {% endif %} # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT=$'\nTask completed in %3lR' time "${@:-help}" diff --git a/templates/php/drupal/run.twig b/templates/php/drupal/run.twig index c083d7b..539edca 100755 --- a/templates/php/drupal/run.twig +++ b/templates/php/drupal/run.twig @@ -159,7 +159,8 @@ function _run { } # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT=$'\nTask completed in %3lR' time "${@:-help}" diff --git a/templates/php/sculpin/run.twig b/templates/php/sculpin/run.twig index 387345d..482cd72 100755 --- a/templates/php/sculpin/run.twig +++ b/templates/php/sculpin/run.twig @@ -35,7 +35,8 @@ function start { } # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT="Task completed in %3lR" time "${@:-help}" diff --git a/templates/terraform/run.twig b/templates/terraform/run.twig index b20aa06..8bbe05f 100755 --- a/templates/terraform/run.twig +++ b/templates/terraform/run.twig @@ -25,7 +25,8 @@ function help { } # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT=$'\nTask completed in %3lR' time "${@:-help}" diff --git a/tests/snapshots/output/drupal-commerce-kickstart/run b/tests/snapshots/output/drupal-commerce-kickstart/run index da6a3ee..59143c9 100755 --- a/tests/snapshots/output/drupal-commerce-kickstart/run +++ b/tests/snapshots/output/drupal-commerce-kickstart/run @@ -103,12 +103,13 @@ function _run { --entrypoint "${command}" \ --no-deps \ --rm \ - ${TTY} \ + "${TTY}" \ "${service}" "${@}" } # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT=$'\nTask completed in %3lR' time "${@:-help}" diff --git a/tests/snapshots/output/drupal-localgov/run b/tests/snapshots/output/drupal-localgov/run index da6a3ee..59143c9 100755 --- a/tests/snapshots/output/drupal-localgov/run +++ b/tests/snapshots/output/drupal-localgov/run @@ -103,12 +103,13 @@ function _run { --entrypoint "${command}" \ --no-deps \ --rm \ - ${TTY} \ + "${TTY}" \ "${service}" "${@}" } # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT=$'\nTask completed in %3lR' time "${@:-help}" diff --git a/tests/snapshots/output/drupal/run b/tests/snapshots/output/drupal/run index 4f786ac..708c254 100755 --- a/tests/snapshots/output/drupal/run +++ b/tests/snapshots/output/drupal/run @@ -121,12 +121,13 @@ function _run { --entrypoint "${command}" \ --no-deps \ --rm \ - ${TTY} \ + "${TTY}" \ "${service}" "${@}" } # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT=$'\nTask completed in %3lR' time "${@:-help}" diff --git a/tests/snapshots/output/fractal/run b/tests/snapshots/output/fractal/run index 3d4b32d..3880ebb 100755 --- a/tests/snapshots/output/fractal/run +++ b/tests/snapshots/output/fractal/run @@ -105,7 +105,8 @@ function _run { } # Include any local tasks. -[[ -e run.local ]] && source run.local +# https://stackoverflow.com/a/6659698 +[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local" TIMEFORMAT=$'\nTask completed in %3lR' time "${@:-help}"