Skip to content

Commit 32c44ce

Browse files
committed
refactor: data_provider_function
1 parent fc7cd14 commit 32c44ce

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/helpers.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ function helper::normalize_variable_name() {
151151
function helper::get_provider_data() {
152152
local function_name="$1"
153153
local script="$2"
154-
local data_provider_function
155154

156155
if [[ ! -f "$script" ]]; then
157156
return
158157
fi
159158

160-
data_provider_function=$(\
161-
grep -B 2 "function $function_name()" "$script" |\
162-
grep -E "# *@?data_provider " |\
163-
sed -E -e 's/\ *# *@?data_provider (.*)$/\1/g'\
164-
|| true
159+
local data_provider_function
160+
data_provider_function=$(
161+
# shellcheck disable=SC1087
162+
grep -B 2 -E "function[[:space:]]+$function_name[[:space:]]*\(\)" "$script" 2>/dev/null | \
163+
grep -E "^[[:space:]]*# *@?data_provider[[:space:]]+" | \
164+
sed -E 's/^[[:space:]]*# *@?data_provider[[:space:]]+//' || true
165165
)
166166

167167
if [[ -n "$data_provider_function" ]]; then

0 commit comments

Comments
 (0)