dsh 832 B

123456789101112131415161718192021
  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. set -eu
  6. # Resolve symlink chains without readlink -f (not on every macOS).
  7. script=$0
  8. while [ -L "$script" ]; do
  9. target=$(readlink "$script")
  10. case $target in
  11. /*) script=$target ;;
  12. *) script=$(dirname "$script")/$target ;;
  13. esac
  14. done
  15. root=$(CDPATH='' cd -- "$(dirname -- "$script")/.." && pwd)
  16. # tsx is imported by absolute path because bare `--import tsx` resolves from
  17. # the invoking cwd, which is usually outside this repository.
  18. export TSX_TSCONFIG_PATH="$root/tsconfig.json"
  19. exec node --import "$root/node_modules/tsx/dist/loader.mjs" "$root/apps/cli/src/bin.ts" "$@"