-
-
Notifications
You must be signed in to change notification settings - Fork 100
chore: add node version check script #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| ```bash | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
| ``` | ||
|
|
||
| # 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| echo "✅ Node version matches .nvmrc." | ||
| else | ||
| echo "⚠️ Node version differs from .nvmrc. Consider running 'nvm use'." | ||
| fi | ||
There was a problem hiding this comment.
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 (
```bashon 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```bashwill be interpreted as an invalid command. The markdown formatting was likely accidentally included when creating the file.