#!/bin/sh
set -eu
if ! command -v node >/dev/null 2>&1; then
  echo "Node.js 20 or newer is required." >&2
  exit 1
fi
NODE_BIN="$(command -v node)"
if ! "$NODE_BIN" -e 'process.exit(Number(process.versions.node.split(".")[0]) >= 20 ? 0 : 1)' \
  >/dev/null 2>&1
then
  echo "Node.js 20 or newer is required (found $("$NODE_BIN" --version))." >&2
  exit 1
fi
exec "$NODE_BIN" "$(dirname "$0")/privcloud-companion.mjs" "$@"
