Skip to content

Commit

Permalink
Fix path in shim
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed Oct 26, 2024
1 parent 932cd14 commit c577430
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bin/preflight.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/usr/bin/env bash

SCRIPT_DIR="${BASH_SOURCE[0]%/*}"
cd "$SCRIPT_DIR" || exit 1
script_dir="$(cd "$(dirname "$0")" && pwd)"

pnpm exec tsx "./src/index.ts"
# Workaround for incorrect path in pnpm shim
# https://github.com/pnpm/pnpm/issues/8704#issuecomment-2439618363
#
# TODO: Remove and switch back to "$script_dir/../node_modules/bin"
# when the issue above is resolved
tsx_shim="$script_dir/../node_modules/.bin/tsx"
exec_command=$(awk '/^else$/{flag=1;next}/^fi$/{flag=0}flag' "$tsx_shim" | grep 'exec node')
cli_path=$(echo "$exec_command" | sed -E 's/^[[:space:]]*exec node[[:space:]]+"([^"]+)".*/\1/')
cli_path="${cli_path/\$basedir/$script_dir}"
cli_path="${cli_path/\/pnpm\//\/pnpm\/global\/5\/.pnpm\/}"

node "$cli_path" "$script_dir/../src/index.ts"

0 comments on commit c577430

Please sign in to comment.