@@ -88,6 +88,7 @@ function terraform_docs {
88
88
local add_to_existing=false
89
89
local create_if_not_exist=false
90
90
local use_standard_markers=true
91
+ local had_config_flag=false
91
92
92
93
IFS=" ;" read -r -a configs <<< " $hook_config"
93
94
@@ -142,10 +143,11 @@ function terraform_docs {
142
143
local tf_docs_formatter=" md"
143
144
144
145
else
145
-
146
+ had_config_flag=true
146
147
local config_file=${args#* --config}
147
148
config_file=${config_file#* =}
148
- config_file=${config_file% * }
149
+ config_file=${config_file% --* }
150
+ args=${args/ --config=$config_file / }
149
151
150
152
# Prioritize `.terraform-docs.yml` `output.file` over
151
153
# `--hook-config=--path-to-file=` if it set
@@ -231,8 +233,13 @@ function terraform_docs {
231
233
have_marker=$( grep -o " $insertion_marker_begin " " $output_file " ) || unset have_marker
232
234
[[ ! $have_marker ]] && popd > /dev/null && continue
233
235
fi
236
+ if [[ $had_config_flag == true ]]; then
237
+ # shellcheck disable=SC2086
238
+ terraform-docs --output-mode=" $output_mode " --output-file=" $output_file " $tf_docs_formatter --config=" $config_file " $args ./ > /dev/null
239
+ else
234
240
# shellcheck disable=SC2086
235
- terraform-docs --output-mode=" $output_mode " --output-file=" $output_file " $tf_docs_formatter $args ./ > /dev/null
241
+ terraform-docs --output-mode=" $output_mode " --output-file=" $output_file " $tf_docs_formatter $config_arg $args ./ > /dev/null
242
+ fi
236
243
237
244
popd > /dev/null
238
245
done
0 commit comments