#!/bin/bash
set -e
DIR="$(cd "$(dirname "$0")" && pwd)"
DEST="/Applications/Markdown Elixir.app"

# Replace any existing install so a re-run doesn't nest the bundle inside itself.
rm -rf "$DEST"

# ditto preserves the symlinks inside the .app's frameworks (Versions/Current
# → Versions/A, etc.). A plain `cp -r` dereferences those symlinks and copies
# each framework binary multiple times, ballooning the app from ~240MB to ~950MB.
ditto "$DIR/Markdown Elixir.app" "$DEST"

# Remove the quarantine / other extended attributes so Gatekeeper lets it open.
xattr -cr "$DEST"

open "$DEST"
echo "Done! Opening Markdown Elixir from Applications folder..."
