qmd 1.1 KB

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. # Resolve symlinks so global installs (npm link / npm install -g) can find the
  3. # actual package directory instead of the global bin directory.
  4. SOURCE="$0"
  5. while [ -L "$SOURCE" ]; do
  6. SOURCE_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
  7. TARGET="$(readlink "$SOURCE")"
  8. case "$TARGET" in
  9. /*) SOURCE="$TARGET" ;;
  10. *) SOURCE="$SOURCE_DIR/$TARGET" ;;
  11. esac
  12. done
  13. # Detect the runtime used to install this package and use the matching one
  14. # to avoid native module ABI mismatches (e.g., better-sqlite3 compiled for bun vs node)
  15. DIR="$(cd -P "$(dirname "$SOURCE")/.." && pwd)"
  16. # Check if we were installed with bun (look for bun.lock or bun-lockb).
  17. # $BUN_INSTALL is intentionally NOT checked here — it only indicates that bun
  18. # exists on the system, not that it was used to install this package. When QMD
  19. # is installed via npm, native modules are compiled for Node and running them
  20. # under bun causes ABI mismatches (e.g. sqlite-vec "no such module: vec0").
  21. if [ -f "$DIR/bun.lock" ] || [ -f "$DIR/bun.lockb" ]; then
  22. exec bun "$DIR/dist/cli/qmd.js" "$@"
  23. else
  24. exec node "$DIR/dist/cli/qmd.js" "$@"
  25. fi