From d9d0d3c444c84a02cd73bbda982dab6a4c229cb3 Mon Sep 17 00:00:00 2001 From: Affaan Mustafa Date: Thu, 12 Feb 2026 16:12:21 -0800 Subject: [PATCH] fix: resolve symlinks in install.sh for npm/bun bin usage When installed via `npm install ecc-universal`, the `ecc-install` bin entry creates a symlink from the package manager's bin directory to install.sh. The old `$(dirname "$0")` resolved to the bin directory instead of the actual package directory, causing `cp` to fail with "cannot stat '.../rules/common/.'". Now follows the symlink chain with readlink before resolving SCRIPT_DIR. Fixes #199 --- install.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f7d9c89..6c868b2 100755 --- a/install.sh +++ b/install.sh @@ -22,7 +22,15 @@ set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +# Resolve symlinks — needed when invoked as `ecc-install` via npm/bun bin symlink +SCRIPT_PATH="$0" +while [ -L "$SCRIPT_PATH" ]; do + link_dir="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)" + SCRIPT_PATH="$(readlink "$SCRIPT_PATH")" + # Resolve relative symlinks + [[ "$SCRIPT_PATH" != /* ]] && SCRIPT_PATH="$link_dir/$SCRIPT_PATH" +done +SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_PATH")" && pwd)" RULES_DIR="$SCRIPT_DIR/rules" # --- Parse --target flag ---