diff --git a/bin/preflight.sh b/bin/preflight.sh new file mode 100755 index 00000000..327ef924 --- /dev/null +++ b/bin/preflight.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +script_dir="$(cd "$(dirname "$0")" && pwd)" +echo "script_dir: $script_dir" + +# 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/tsx" +# 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:]]+"[^"]+(node_modules\/tsx\/[^"]+)".*/\1/') +cli_path="$(pnpm bin --global)/global/5/.pnpm/$cli_path" +# # pnpm_bin_global="$(pnpm bin --global)/global/5/.pnpm/$cli_path" +# # echo "pnpm_bin_global: $pnpm_bin_global" +# cli_path="${cli_path/$pnpm_bin_global\//$pnpm_bin_global\/global\/5\/.pnpm\/}" +# echo "cli_path: $cli_path" + +node "$cli_path" "$script_dir/../src/index.ts" diff --git a/bin/preflight.ts b/bin/preflight.ts deleted file mode 100755 index 12968d35..00000000 --- a/bin/preflight.ts +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env -S pnpm exec tsx - -import '../src/index.ts'; diff --git a/package.json b/package.json index 81919471..49de5da3 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "module": "./src/index.ts", "types": "./src/index.ts", "bin": { - "preflight": "./bin/preflight.ts" + "preflight": "./bin/preflight.sh" }, "files": [ "./bin/preflight.js",