Skip to content

Commit 8fd829e

Browse files
committed
chore(cli): refactor version checks and enforce curl dependency
- Make get_latest_version a function using consistent function syntax - Add a check to ensure curl is installed before proceeding Signed-off-by: appleboy <[email protected]>
1 parent a5bce4e commit 8fd829e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

install.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function add_to_path() {
9090
}
9191

9292
# Fetch latest release version from GitHub if VERSION is not set
93-
get_latest_version() {
93+
function get_latest_version() {
9494
local latest
9595
if command -v jq >/dev/null 2>&1; then
9696
latest=$(curl $INSECURE_OPTION -# --retry 5 -fSL https://api.github.com/repos/appleboy/CodeGPT/releases/latest | jq -r .tag_name)
@@ -102,6 +102,13 @@ get_latest_version() {
102102
echo "$latest"
103103
}
104104

105+
# Check for required commands
106+
for cmd in curl; do
107+
if ! command -v "$cmd" >/dev/null 2>&1; then
108+
log_error "Error: $cmd is not installed. Please install $cmd to proceed." 1
109+
fi
110+
done
111+
105112
CURL_INSECURE="${CURL_INSECURE:-false}"
106113
if [[ "${CURL_INSECURE}" != 'true' && "${CURL_INSECURE}" != 'false' ]]; then
107114
log_error "CURL_INSECURE must be either 'true' or 'false'" 4

0 commit comments

Comments
 (0)