Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions scripts/check-node-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
```bash
#!/usr/bin/env bash
set -euo pipefail
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Markdown code fences break shell script execution

The script contains markdown code fence markers (```bash on line 1 and ``` on line 4) that are not valid bash syntax. This causes the script to fail on execution since the shebang must be on line 1, and ```bash will be interpreted as an invalid command. The markdown formatting was likely accidentally included when creating the file.

Fix in Cursor Fix in Web


# Checks that the current Node.js version roughly matches the one in .nvmrc.
# This is a small helper for contributors who don't use nvm directly.

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${ROOT_DIR}"

if [ ! -f .nvmrc ]; then
echo ".nvmrc not found in project root."
exit 0
fi

EXPECTED_VERSION="$(tr -d ' \n' < .nvmrc)"
CURRENT_VERSION="$(node -v 2>/dev/null || echo "unknown")"

echo "Expected Node version (from .nvmrc): ${EXPECTED_VERSION}"
echo "Current Node version: ${CURRENT_VERSION}"

if [ "${CURRENT_VERSION}" = "unknown" ]; then
echo "⚠️ Node.js is not available on PATH."
exit 1
fi

if [ "${CURRENT_VERSION}" = "${EXPECTED_VERSION}" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Version comparison fails for nvm aliases like lts/*

The exact string comparison between CURRENT_VERSION (from node -v, e.g., v20.10.0) and EXPECTED_VERSION (from .nvmrc) will never succeed when .nvmrc contains an nvm alias like lts/*. Since the repository's .nvmrc actually contains lts/*, this script will always report a version mismatch even when the correct Node version is installed, making it ineffective for its intended purpose.

Fix in Cursor Fix in Web

echo "✅ Node version matches .nvmrc."
else
echo "⚠️ Node version differs from .nvmrc. Consider running 'nvm use'."
fi