#!/bin/sh
# Starts this project's verification tool, verify.mts beside this file: TypeScript that Node
# 22.18 or newer (23.6 or newer on Node 23) runs directly. `verify --help` says everything else.
# A project that ports the tool to another language keeps this file's name and replaces
# everything below this comment, the Node check included, with a line that starts the port.
v=$(node --version 2>/dev/null) || { echo "verify: needs Node 22.18 or newer (https://nodejs.org); node was not found" >&2; exit 3; }
major=${v#v}; minor=${major#*.}; major=${major%%.*}; minor=${minor%%.*}
if [ "$major" -lt 22 ] || { [ "$major" -eq 22 ] && [ "$minor" -lt 18 ]; } || { [ "$major" -eq 23 ] && [ "$minor" -lt 6 ]; }; then
  echo "verify: needs Node 22.18 or newer (23.6 or newer on Node 23), which runs TypeScript directly; found $v" >&2
  exit 3
fi
exec node "$(dirname "$0")/verify.mts" "$@"
