Skip to content

Commit

Permalink
Ensure run.local files are located relative to the
Browse files Browse the repository at this point in the history
...run file

Prevent erroring if `run` is being executed within a sub-directory, like
`assets`.
  • Loading branch information
opdavies committed Jul 31, 2024
1 parent ac82467 commit 4e255cd
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 11 deletions.
3 changes: 2 additions & 1 deletion templates/fractal/run.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion templates/php/drupal/run.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion templates/php/sculpin/run.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion templates/terraform/run.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
5 changes: 3 additions & 2 deletions tests/snapshots/output/drupal-commerce-kickstart/run
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
5 changes: 3 additions & 2 deletions tests/snapshots/output/drupal-localgov/run
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
5 changes: 3 additions & 2 deletions tests/snapshots/output/drupal/run
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 2 additions & 1 deletion tests/snapshots/output/fractal/run
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 4e255cd

Please sign in to comment.