Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/crabcode
Original file line number Diff line number Diff line change
Expand Up @@ -9308,10 +9308,17 @@ main() {
local install_dir=$(dirname "$(realpath "$0")")
local tmp_file="/tmp/crabcode-update-$$"

if curl -fsSL "https://raw.githubusercontent.com/promptfoo/crabcode/main/src/crabcode" -o "$tmp_file" 2>/dev/null; then
local new_version=$(grep '^VERSION=' "$tmp_file" | cut -d'"' -f2)
# Cache-bust to bypass GitHub raw CDN cache (max-age=300)
if curl -fsSL -H 'Cache-Control: no-cache' "https://raw.githubusercontent.com/promptfoo/crabcode/main/src/crabcode?t=$(date +%s)" -o "$tmp_file" 2>/dev/null; then
local new_version=$(grep '^VERSION=' "$tmp_file" | head -1 | cut -d'"' -f2)
local current_version="$VERSION"

if [ -z "$new_version" ]; then
error "Downloaded file is invalid (no version found)"
rm -f "$tmp_file"
exit 1
fi

if [ "$new_version" = "$current_version" ]; then
echo -e "${GREEN}Already up to date (v$VERSION)${NC}"
else
Expand Down