1
0
Fork 0
mirror of https://github.com/imjasonh/apidiff-action synced 2026-07-06 22:52:43 +00:00
apidiff-action/scripts/use-node-20.sh
Jason Hall 051f997977
Enforce Node 20 in pre-commit hooks
- Add Node version check to build-dist pre-commit hook
- Create helper script to switch to Node 20
- Update documentation with clear instructions
- Fix YAML syntax in pre-commit config

This ensures dist is always built with Node 20, preventing CI failures
due to version mismatches.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 09:22:44 -04:00

27 lines
649 B
Bash
Executable file

#!/bin/bash
# Helper script to ensure Node 20 is being used
# Check if nvm is available
if ! command -v nvm &> /dev/null; then
if [ -f "$HOME/.nvm/nvm.sh" ]; then
source "$HOME/.nvm/nvm.sh"
else
echo "Error: nvm is not installed or not loaded"
echo "Please install nvm or source it in your shell"
exit 1
fi
fi
# Install Node 20 if needed and switch to it
echo "Switching to Node 20..."
nvm install
nvm use
# Verify we're on Node 20
node_version=$(node --version)
if [[ ! "$node_version" =~ ^v20\. ]]; then
echo "Error: Failed to switch to Node 20 (current: $node_version)"
exit 1
fi
echo "✓ Using Node $node_version"