0
0
mirror of https://github.com/yeongpin/cursor-free-vip.git synced 2025-04-24 08:25:23 +00:00

fix(script): avoid empty version when call release api

Also enhance the way for judging $?
This commit is contained in:
imbajin 2025-03-14 15:11:57 +08:00
parent 3200271156
commit 9b5912357d

15
scripts/install.sh Normal file → Executable file
View File

@ -39,14 +39,17 @@ get_downloads_dir() {
# Get latest version # Get latest version
get_latest_version() { get_latest_version() {
echo -e "${CYAN} Checking latest version...${NC}" echo -e "${CYAN} Checking latest version...${NC}"
local latest_release latest_release=$(curl -s https://api.github.com/repos/yeongpin/cursor-free-vip/releases/latest) || {
latest_release=$(curl -s https://api.github.com/repos/yeongpin/cursor-free-vip/releases/latest)
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Cannot get latest version information${NC}" echo -e "${RED}❌ Cannot get latest version information${NC}"
exit 1 exit 1
fi }
VERSION=$(echo "$latest_release" | grep -o '"tag_name": ".*"' | cut -d'"' -f4 | tr -d 'v') VERSION=$(echo "$latest_release" | grep -o '"tag_name": ".*"' | cut -d'"' -f4 | tr -d 'v')
if [ -z "$VERSION" ]; then
echo -e "${RED}❌ Failed to parse version from GitHub API response:\n${latest_release}"
exit 1
fi
echo -e "${GREEN}✅ Found latest version: ${VERSION}${NC}" echo -e "${GREEN}✅ Found latest version: ${VERSION}${NC}"
} }
@ -170,9 +173,7 @@ install_cursor_free_vip() {
fi fi
echo -e "${CYAN} Setting executable permissions...${NC}" echo -e "${CYAN} Setting executable permissions...${NC}"
chmod +x "${binary_path}" if chmod +x "${binary_path}"; then
if [ $? -eq 0 ]; then
echo -e "${GREEN}✅ Installation completed!${NC}" echo -e "${GREEN}✅ Installation completed!${NC}"
echo -e "${CYAN} Program downloaded to: ${binary_path}${NC}" echo -e "${CYAN} Program downloaded to: ${binary_path}${NC}"
echo -e "${CYAN} Starting program...${NC}" echo -e "${CYAN} Starting program...${NC}"