dsh 934 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. # dsh launcher: runs the apps/cli `dsh` bin FROM SOURCE with this checkout's
  3. # tsx, so a symlink from anywhere (e.g. ~/.local/bin/dsh) always executes the
  4. # current working tree — code changes apply on the next launch, no build step.
  5. # --expose-internals: the shipped config mounts HMR, which needs Loader internals.
  6. set -eu
  7. # Resolve symlink chains without readlink -f (not on every macOS).
  8. script=$0
  9. while [ -L "$script" ]; do
  10. target=$(readlink "$script")
  11. case $target in
  12. /*) script=$target ;;
  13. *) script=$(dirname "$script")/$target ;;
  14. esac
  15. done
  16. root=$(CDPATH='' cd -- "$(dirname -- "$script")/.." && pwd)
  17. # tsx is imported by absolute path because bare `--import tsx` resolves from
  18. # the invoking cwd, which is usually outside this repository.
  19. export TSX_TSCONFIG_PATH="$root/tsconfig.json"
  20. exec node --expose-internals --import "$root/node_modules/tsx/dist/loader.mjs" "$root/apps/cli/src/bin.ts" "$@"