Skip to content

Instantly share code, notes, and snippets.

@aroemers
Last active December 18, 2021 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aroemers/c08d51c411718176048e2af572269c2f to your computer and use it in GitHub Desktop.
Save aroemers/c08d51c411718176048e2af572269c2f to your computer and use it in GitHub Desktop.
Tailwind CLI wrapper script
#!/usr/bin/env bash
set -e
TAILWIND_VERSION="${TAILWIND_VERSION:-v3.0.7}"
# Determine correct binary
ARCHTYPE=$(uname -m)
case "$ARCHTYPE" in
x86_64) ARCH="x64" ;;
arm) ARCH="arm64" ;;
*) echo "Unknown/unsupported architucture: $ARCHTYPE"; exit 1 ;;
esac
case "$OSTYPE" in
darwin*) TAILWIND_CLI="tailwindcss-macos-$ARCH" ;;
linux*) TAILWIND_CLI="tailwindcss-linux-$ARCH" ;;
*) echo "Unknown/unsupported OS: $OSTYPE"; exit 1 ;;
esac
# Path to this script's directory
SCRIPTDIR=$(dirname "$0")
# Expected location of cli binary
CLIDIR="$SCRIPTDIR/.tailwind/wrapper/$TAILWIND_VERSION"
CLI="$CLIDIR/$TAILWIND_CLI"
# Download if binary not exists
if [ ! -f "$CLI" ]; then
TAILWIND_DOWNLOAD="https://github.com/tailwindlabs/tailwindcss/releases/download/$TAILWIND_VERSION/$TAILWIND_CLI"
echo "Downloading $TAILWIND_DOWNLOAD to $CLIDIR ..."
curl -L -o "$CLI" --create-dirs "$TAILWIND_DOWNLOAD"
chmod +x "$CLI"
fi
echo "Tailwind wrapper executing: $CLI $@"
"$CLI" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment