From 9f4c71c783969d3d3d0510ebd272ae1772388316 Mon Sep 17 00:00:00 2001 From: nkkko Date: Tue, 10 Mar 2026 22:38:20 +0100 Subject: [PATCH] fix(cli): resolve symlinked global launcher path --- bin/qmd | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/qmd b/bin/qmd index 32a8fd7..967641f 100755 --- a/bin/qmd +++ b/bin/qmd @@ -1,8 +1,19 @@ #!/bin/sh +# Resolve symlinks so global installs (npm link / npm install -g) can find the +# actual package directory instead of the global bin directory. +SOURCE="$0" +while [ -L "$SOURCE" ]; do + SOURCE_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" + TARGET="$(readlink "$SOURCE")" + case "$TARGET" in + /*) SOURCE="$TARGET" ;; + *) SOURCE="$SOURCE_DIR/$TARGET" ;; + esac +done + # Detect the runtime used to install this package and use the matching one # to avoid native module ABI mismatches (e.g., better-sqlite3 compiled for bun vs node) - -DIR="$(cd "$(dirname "$0")/.." && pwd)" +DIR="$(cd -P "$(dirname "$SOURCE")/.." && pwd)" # Check if we were installed with bun (look for bun.lock or bun-lockb) if [ -f "$DIR/bun.lock" ] || [ -f "$DIR/bun.lockb" ] || [ -n "$BUN_INSTALL" ]; then