Skip to content

Commit c9837e7

Browse files
authored
update check for required command cli
1 parent 781dc21 commit c9837e7

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

slice.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,25 @@
3232

3333
set -euo pipefail
3434

35-
if [[ -n "${ENABLE_SUBTREE_PUSH}" ]] ; then
35+
for _i in bash git ; do
36+
if ! command -v "${_i}" &> /dev/null ; then
37+
>&2 echo "ERROR: ${_i} is not installed."
38+
_will_exit=1
39+
fi
40+
done
41+
if [[ -n "${ENABLE_SUBTREE_PUSH:+x}" ]] ; then
3642
if [[ -z "${ACCESS_TOKEN}" ]] ; then
3743
>&2 echo "ERROR: \${ACCESS_TOKEN} environment not provided."
3844
exit 1
3945
fi
40-
if ! command -v gh &> /dev/null; then
41-
>&2 echo "ERROR: GitHub CLI is not installed. Required to create remote subtree repo."
42-
exit 1
43-
fi
46+
for _i in gh curl awk ; do
47+
if ! command -v "${_i}" &> /dev/null ; then
48+
>&2 echo "ERROR: ${_i} is not installed."
49+
_will_exit=1
50+
fi
51+
done
4452
fi
53+
[ -n "${_will_exit:+x}" ] && exit 1
4554

4655
_git_subtree_branch_prefix="___"
4756

@@ -64,7 +73,8 @@ for _i in "${@}" ; do
6473

6574
done
6675

67-
if [[ -n "${ENABLE_SUBTREE_PUSH}" ]] ; then
76+
77+
if [[ -n "${ENABLE_SUBTREE_PUSH:+x}" ]] ; then
6878

6979
readarray -t _git_branches < <(git branch --list "${_git_subtree_branch_prefix}*")
7080

0 commit comments

Comments
 (0)