Skip to content

Instantly share code, notes, and snippets.

@AdamGagorik
Created April 26, 2024 13:37
Show Gist options
  • Save AdamGagorik/a5e7d2bb6c5ba6e5c76011aabb801033 to your computer and use it in GitHub Desktop.
Save AdamGagorik/a5e7d2bb6c5ba6e5c76011aabb801033 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CACHE_FILE="${SCRIPT_DIR}/latest-clion-version.txt"
CACHE_TTL=$((60 * 60 * 24 * 7))
if [[ "$#" -gt 0 ]]; then
if [[ "$1" = "-f" ]] || [[ "$1" = "--force" ]]; then
FORCE=1
else
echo "usage: $0 --force"
exit 1
fi
fi
if [[ -f "$CACHE_FILE" && $(( $(date +%s) - $(stat -c %Y "$CACHE_FILE") )) -lt $CACHE_TTL ]] && [[ -z "${FORCE}" ]]; then
cat "$CACHE_FILE"
else
>&2 echo "Fetching latest CLion version"
curl -s "https://data.services.jetbrains.com/products/releases?code=CL&latest=true&type=release" | jq -r '.CL[0].version' > "${CACHE_FILE}"
cat "$CACHE_FILE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment