-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathcmd-mod.bash
More file actions
31 lines (28 loc) · 843 Bytes
/
cmd-mod.bash
File metadata and controls
31 lines (28 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# shellcheck shell=bash
# shellcheck source=./common.bash
. "$(dirname "${0}")/lib/common.bash"
prepare_file_hook_cmd "$@"
if [ "${use_dot_dot_dot:-}" -eq 1 ]; then
OPTIONS+=('./...')
fi
export GO111MODULE=on
error_code=0
# Assume parent folder of go.mod is module root folder
#
for sub in $(find_module_roots "${FILES[@]}" | sort -u); do
pushd "${sub}" > /dev/null || exit 1
if [ "${use_path_prefix:-}" -eq 1 ] && [ "${cmd_cwd_arg:-}" ]; then
OPTIONS+=("${cmd_cwd_arg//\{\{sub\}\}/"$sub"}")
fi
if [ "${error_on_output:-}" -eq 1 ]; then
output=$(/usr/bin/env "${ENV_VARS[@]}" "${cmd[@]}" "${OPTIONS[@]}" 2>&1)
if [ -n "${output}" ]; then
printf "%s\n" "${output}"
error_code=1
fi
elif ! /usr/bin/env "${ENV_VARS[@]}" "${cmd[@]}" "${OPTIONS[@]}"; then
error_code=1
fi
popd > /dev/null || exit 1
done
exit $error_code