Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to find and launch the built ConjurerBridge application #285

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"prod": "src/scripts/try-start-unity-bridge.sh; next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
Expand Down
43 changes: 43 additions & 0 deletions src/scripts/try-start-unity-bridge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# Try to open the Unity bridge when on MacOs
if [[ "$OSTYPE" = "darwin"* ]]; then
# Define the application name pattern (e.g., MyApp_v*.app)
APP_NAME_PATTERN="ConjurerBridge_v*.app"

# Look for all applications matching the pattern in /Applications
APP_PATHS=($(find /Applications -maxdepth 1 -name "$APP_NAME_PATTERN"))

# Check if any application was found
if [[ ${#APP_PATHS[@]} -eq 0 ]]; then
echo "No Unity bridge application found matching the pattern $APP_NAME_PATTERN in /Applications."
else
# Extract version numbers from the app names and sort them to find the latest
LATEST_APP=""
LATEST_VERSION=""

for APP_PATH in "${APP_PATHS[@]}"; do
echo "Found Unity bridge application: $APP_PATH"
# Extract version number from the app name using regex
VERSION=$(echo "$APP_PATH" | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')
if [[ -z "$VERSION" ]]; then
continue
fi

# Compare versions and keep the latest
if [[ -z "$LATEST_VERSION" || "$VERSION" > "$LATEST_VERSION" ]]; then
LATEST_VERSION="$VERSION"
LATEST_APP="$APP_PATH"
fi
done
fi
# Check if we found the latest app
if [[ -z "$LATEST_APP" ]]; then
echo "No valid versioned application found."
else
# Launch the latest application
echo "Latest = $LATEST_VERSION"
echo "Launching $LATEST_APP"
open "$LATEST_APP"
fi
fi
Loading