File size: 1,515 Bytes
3fbbdd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
#
# Launch the Logseq desktop app.
#
# Locates the built Logseq.app relative to this script (no absolute paths) and
# opens it. Works standalone -- build.sh does not need to have been sourced.
#
# Search order:
#   1. $APP_OUTPUT_DIR/Logseq.app        (if APP_OUTPUT_DIR is set)
#   2. <script dir>/Logseq.app           (default build.sh output copy)
#   3. <script dir>/static/out/Logseq-darwin-*/Logseq.app  (electron-forge output)

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"

find_app() {
  local candidates=()
  if [ -n "${APP_OUTPUT_DIR:-}" ]; then
    candidates+=("$APP_OUTPUT_DIR/Logseq.app")
  fi
  candidates+=("$SCRIPT_DIR/Logseq.app")

  local c
  for c in "${candidates[@]}"; do
    if [ -d "$c" ]; then
      printf '%s\n' "$c"
      return 0
    fi
  done

  # Fall back to the electron-forge output directory (any arch).
  local found
  found="$(find "$SCRIPT_DIR/static/out" -maxdepth 2 -name 'Logseq.app' -type d 2>/dev/null | head -1 || true)"
  if [ -n "$found" ]; then
    printf '%s\n' "$found"
    return 0
  fi
  return 1
}

APP_PATH="$(find_app || true)"

if [ -z "${APP_PATH:-}" ] || [ ! -d "$APP_PATH" ]; then
  echo "ERROR: Could not find Logseq.app. Run build.sh first." >&2
  exit 1
fi

echo "Launching: $APP_PATH"

# Electron bundles everything it needs, so no DYLD_/QT_ environment is required.
# Use `open -W` so the script tracks the app's lifetime; pass through any args.
exec open -W "$APP_PATH" --args --force-renderer-accessibility "$@"