lib/reloader: adopt `_bash-it-log-prefix-by-path()`

pull/2055/head
John D Pell 2021-10-12 23:21:30 -07:00 committed by John D Pell
parent 7e79212dff
commit 75d22d865f
1 changed files with 2 additions and 10 deletions

View File

@ -1,14 +1,6 @@
#!/bin/bash #!/bin/bash
BASH_IT_LOG_PREFIX="core: reloader: " BASH_IT_LOG_PREFIX="core: reloader: "
function _set-prefix-based-on-path()
{
filename=$(_bash-it-get-component-name-from-path "$1")
extension=$(_bash-it-get-component-type-from-path "$1")
# shellcheck disable=SC2034
BASH_IT_LOG_PREFIX="$extension: $filename: "
}
if [[ "$1" != "skip" ]] && [[ -d "$BASH_IT/enabled" ]]; then if [[ "$1" != "skip" ]] && [[ -d "$BASH_IT/enabled" ]]; then
_bash_it_config_type="" _bash_it_config_type=""
@ -22,7 +14,7 @@ if [[ "$1" != "skip" ]] && [[ -d "$BASH_IT/enabled" ]]; then
for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/enabled/*${_bash_it_config_type}.bash")); do for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/enabled/*${_bash_it_config_type}.bash")); do
if [ -e "${_bash_it_config_file}" ]; then if [ -e "${_bash_it_config_file}" ]; then
_set-prefix-based-on-path "${_bash_it_config_file}" _bash-it-log-prefix-by-path "${_bash_it_config_file}"
_log_debug "Loading component..." _log_debug "Loading component..."
# shellcheck source=/dev/null # shellcheck source=/dev/null
source $_bash_it_config_file source $_bash_it_config_file
@ -38,7 +30,7 @@ if [[ -n "${2}" ]] && [[ -d "$BASH_IT/${2}/enabled" ]]; then
_log_warning "Using legacy enabling for $2, please update your bash-it version and migrate" _log_warning "Using legacy enabling for $2, please update your bash-it version and migrate"
for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/${2}/enabled/*.bash")); do for _bash_it_config_file in $(sort <(compgen -G "$BASH_IT/${2}/enabled/*.bash")); do
if [[ -e "$_bash_it_config_file" ]]; then if [[ -e "$_bash_it_config_file" ]]; then
_set-prefix-based-on-path "${_bash_it_config_file}" _bash-it-log-prefix-by-path "${_bash_it_config_file}"
_log_debug "Loading component..." _log_debug "Loading component..."
# shellcheck source=/dev/null # shellcheck source=/dev/null
source "$_bash_it_config_file" source "$_bash_it_config_file"