Skip to content

Commit 3ff581a

Browse files
committed
refactor(cursor): use lib shim helpers, remove duplicate logic
- Drop local REPO_*, SHARED_SHIM, SHIM_*, ensure_shim, refresh_shim_assets - Call refresh_shim_assets in update_cursor, run_ensure_shim in install paths
1 parent b8d7ea4 commit 3ff581a

1 file changed

Lines changed: 3 additions & 42 deletions

File tree

cursor.sh

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ fi
2121

2222
CLI_NAME="cursor-installer"
2323
CLI_BIN="$HOME/.local/bin/$CLI_NAME"
24-
REPO_OWNER=${REPO_OWNER:-watzon}
25-
REPO_BRANCH=${REPO_BRANCH:-main}
26-
REPO_NAME=${REPO_NAME:-cursor-linux-installer}
27-
BASE_RAW_URL="https://raw.githubusercontent.com/${REPO_OWNER}/${REPO_NAME}/${REPO_BRANCH}"
28-
SHARED_SHIM="$LIB_DIR/shim.sh"
29-
SHIM_URL="$BASE_RAW_URL/shim.sh"
30-
SHIM_HELPER="$LIB_DIR/ensure-shim.sh"
31-
SHIM_HELPER_URL="$BASE_RAW_URL/scripts/ensure-shim.sh"
3224

3325
# Installation mode: 'appimage' (default) or 'extracted'
3426
# Can be set via CURSOR_INSTALL_MODE environment variable or --extract flag
@@ -48,44 +40,13 @@ function get_extracted_root() {
4840
fi
4941
done
5042
return 1
51-
}
43+
}
5244

5345
function get_extraction_dir() {
5446
# Prefer ~/.local/share/cursor for extracted installations
5547
echo "$HOME/.local/share/cursor"
5648
}
5749

58-
function ensure_shim() {
59-
if [ -x "$SHIM_HELPER" ]; then
60-
if ! "$SHIM_HELPER"; then
61-
log_warn "Shim update failed; continuing."
62-
fi
63-
return 0
64-
fi
65-
if [ -f "$SHIM_HELPER" ]; then
66-
if ! sh "$SHIM_HELPER"; then
67-
log_warn "Shim update failed; continuing."
68-
fi
69-
return 0
70-
fi
71-
log_info "Shim helper not found; skipping shim update."
72-
return 0
73-
}
74-
75-
function refresh_shim_assets() {
76-
log_step "Refreshing cursor shim assets..."
77-
mkdir -p "$LIB_DIR"
78-
if ! curl -fsSL "$SHIM_URL" -o "$SHARED_SHIM"; then
79-
log_warn "Failed to download shim.sh; continuing."
80-
return 0
81-
fi
82-
if ! curl -fsSL "$SHIM_HELPER_URL" -o "$SHIM_HELPER"; then
83-
log_warn "Failed to download ensure-shim.sh; continuing."
84-
return 0
85-
fi
86-
chmod +x "$SHIM_HELPER" "$SHARED_SHIM" || true
87-
}
88-
8950
function check_fuse() {
9051
# First, check if FUSE is already available
9152
if fusermount -V >/dev/null 2>&1; then
@@ -328,7 +289,7 @@ EOF
328289
}
329290

330291
function install_cursor_extracted() {
331-
ensure_shim
292+
run_ensure_shim
332293
local install_dir="$1"
333294
local release_track=${2:-stable}
334295
local temp_file
@@ -478,7 +439,7 @@ function install_cursor_extracted() {
478439
}
479440

480441
function install_cursor() {
481-
ensure_shim
442+
run_ensure_shim
482443
local install_dir="$1"
483444
local release_track=${2:-stable} # Default to stable if not specified
484445

0 commit comments

Comments
 (0)