Skip to content

Commit 6455607

Browse files
committed
use: Push logic from use_modules to find_module
This is part of the refactoring of `_GO_USE_MODULES` to provide correct `@go` command script scope for plugin modules.
1 parent 417fd6d commit 6455607

File tree

1 file changed

+16
-15
lines changed
  • lib/internal

1 file changed

+16
-15
lines changed

lib/internal/use

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,25 @@ _@go.find_plugin_module() {
7878
}
7979

8080
_@go.find_module() {
81-
__go_module_file="$_GO_SCRIPTS_DIR/lib/$__go_module_name"
81+
if [[ -n "$_GO_INJECT_MODULE_PATH" ]]; then
82+
__go_module_file="$_GO_INJECT_MODULE_PATH/$__go_module_name"
83+
if [[ -f "$__go_module_file" ]]; then
84+
return
85+
fi
86+
fi
87+
__go_module_file="$_GO_CORE_DIR/lib/$__go_module_name"
8288

8389
if [[ ! -f "$__go_module_file" ]]; then
84-
__go_module_file="$_GO_ROOTDIR/lib/$__go_module_name"
90+
__go_module_file="$_GO_SCRIPTS_DIR/lib/$__go_module_name"
8591

8692
if [[ ! -f "$__go_module_file" ]]; then
87-
# Convert <plugin>/<module> to plugins/<plugin>/lib/<module>
88-
__go_module_file="${__go_module_name/\///lib/}"
89-
@go.search_plugins '_@go.find_plugin_module'
93+
__go_module_file="$_GO_ROOTDIR/lib/$__go_module_name"
94+
95+
if [[ ! -f "$__go_module_file" ]]; then
96+
# Convert <plugin>/<module> to plugins/<plugin>/lib/<module>
97+
__go_module_file="${__go_module_name/\///lib/}"
98+
@go.search_plugins '_@go.find_plugin_module'
99+
fi
90100
fi
91101
fi
92102
}
@@ -109,16 +119,7 @@ _@go.use_modules() {
109119
fi
110120

111121
for __go_module_name in "$@"; do
112-
__go_module_file="$_GO_CORE_DIR/lib/$__go_module_name"
113-
114-
if [[ -n "$_GO_INJECT_MODULE_PATH" ]]; then
115-
__go_module_file="$_GO_INJECT_MODULE_PATH/$__go_module_name"
116-
if [[ ! -f "$__go_module_file" ]]; then
117-
__go_module_file="$_GO_CORE_DIR/lib/$__go_module_name"
118-
fi
119-
fi
120-
121-
if [[ ! -f "$__go_module_file" ]] && ! _@go.find_module; then
122+
if ! _@go.find_module; then
122123
@go.printf 'ERROR: Module %s not found at:\n' "$__go_module_name" >&2
123124
@go.print_stack_trace 1 >&2
124125
exit 1

0 commit comments

Comments
 (0)