Skip to content
11 changes: 9 additions & 2 deletions src/claude-code/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ install_nodejs() {
# Function to install Claude Code CLI
install_claude_code() {
echo "Installing Claude Code CLI..."
npm install -g @anthropic-ai/claude-code
local npm_version npm_major_version
npm_version="$(npm --version)"
npm_major_version="${npm_version%%.*}"
if [ "$npm_major_version" -ge 12 ] 2>/dev/null; then
npm install -g @anthropic-ai/claude-code --allow-scripts=@anthropic-ai/claude-code
else
npm install -g @anthropic-ai/claude-code
fi

Comment thread
tobi1220 marked this conversation as resolved.
if command -v claude >/dev/null; then
echo "Claude Code CLI installed successfully!"
Expand Down Expand Up @@ -137,4 +144,4 @@ main() {
}

# Execute main function
main
main
17 changes: 17 additions & 0 deletions test/claude-code/auto-install-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

# Validate the auto-install path installed Node.js 18 from NodeSource.
if ! node --version | grep -q "^v18\."; then
echo "expected Node.js 18.x from auto-install path"
exit 1
fi

if [ ! -f /etc/apt/sources.list.d/nodesource.list ]; then
echo "expected NodeSource apt source list to exist"
exit 1
fi

echo "Auto-install Node.js scenario checks passed!"
exit 0
6 changes: 6 additions & 0 deletions test/claude-code/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
"ghcr.io/devcontainers/features/node:1": {},
"claude-code": {}
}
},
"auto-install-node": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"claude-code": {}
}
}
}