Skip to content

Commit c37307a

Browse files
committed
Create get_custom_executable_path function to hold the custom exec path logic
1 parent cdf648c commit c37307a

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

bin/private/asdf-exec

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ for version in "${versions[@]}"; do
2727
exit 127
2828
fi
2929

30-
# custom plugin hook for executable path
31-
if [ -f "${plugin_path}/bin/exec-path" ]; then
32-
cmd=$(basename "$executable_path")
33-
executable_path="$("${plugin_path}/bin/exec-path" "$install_path" "$cmd" "$executable_path")"
34-
fi
30+
executable_path=$(get_custom_executable_path "$plugin_path" "$install_path" "$executable_path")
3531

3632
if full_executable_path=$(get_executable_path "$plugin_name" "$version" "$executable_path"); then
3733
if [ -f "$full_executable_path" ]; then

lib/commands/which.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ which_command() {
1212
if [ "$version" = "system" ]; then
1313
continue
1414
fi
15-
if [ -f "${plugin_path}/bin/exec-path" ]; then
16-
cmd=$(basename "$executable_path")
17-
install_path=$(find_install_path "$plugin_name" "$version")
18-
executable_path="$("${plugin_path}/bin/exec-path" "$install_path" "$cmd" "$executable_path")"
19-
fi
15+
16+
executable_path="$(get_custom_executable_path "$plugin_path" "$install_path" "$executable_path")"
2017
full_executable_path=$(get_executable_path "$plugin_name" "$version" "$executable_path")
2118
location=$(find -L "$full_executable_path" -maxdepth 4 -name "$command" -type f -perm -u+x | sed -e 's|//|/|g')
19+
2220
if [ -n "$location" ]; then
2321
echo "$location"
2422
not_found=0

lib/utils.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,20 @@ find_install_path() {
220220
fi
221221
}
222222

223+
get_custom_executable_path() {
224+
local plugin_path=$1
225+
local install_path=$2
226+
local executable_path=$3
227+
228+
# custom plugin hook for executable path
229+
if [ -f "${plugin_path}/bin/exec-path" ]; then
230+
cmd=$(basename "$executable_path")
231+
executable_path="$("${plugin_path}/bin/exec-path" "$install_path" "$cmd" "$executable_path")"
232+
fi
233+
234+
echo $executable_path
235+
}
236+
223237
get_executable_path() {
224238
local plugin_name=$1
225239
local version=$2

0 commit comments

Comments
 (0)