#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
VERSION="22.22.0"
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
case "$ARCH" in
  arm64|aarch64) ARCH="arm64" ;;
  x86_64|amd64) ARCH="x64" ;;
esac
NODE="$ROOT/.toolchain/node-v${VERSION}-${OS}-${ARCH}/bin/node"
if [[ ! -x "$NODE" ]]; then
  echo "Run ./scripts/install-node.sh first" >&2
  exit 1
fi
exec "$NODE" "$@"
