fix: robust node.js version parsing in installers
Improved Node.js version check logic to handle prefixed version strings and avoid brittle cut commands. Verified with multiple version formats including v24.11.1.
This commit is contained in:
@@ -108,14 +108,21 @@ check_nodejs() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local node_version=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
|
||||
if [ "$node_version" -lt 18 ]; then
|
||||
log_error "Node.js version $node_version is too old!"
|
||||
echo "Node.js 18 or newer is required."
|
||||
local node_full_version=$(node -v 2>&1)
|
||||
local node_version=$(echo "$node_full_version" | grep -oE '[0-9]+' | head -n1)
|
||||
|
||||
if [ -z "$node_version" ]; then
|
||||
log_error "Could not parse Node.js version from: $node_full_version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_success "Node.js $(node -v) found"
|
||||
if [ "$node_version" -lt 18 ]; then
|
||||
log_error "Node.js version $node_version is too old!"
|
||||
echo "Node.js 18 or newer is required. Found: $node_full_version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_success "Node.js $node_full_version found"
|
||||
}
|
||||
|
||||
check_claude_code_installed() {
|
||||
|
||||
Reference in New Issue
Block a user