Reformat misc/tools.func with consistent indentation
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Updated the entire misc/tools.func script to use consistent 2-space indentation for improved readability and maintainability. No functional changes were made.
This commit is contained in:
parent
5ae38e84c8
commit
f55fa4f60e
@ -3096,8 +3096,21 @@ function setup_nodejs() {
|
||||
msg_info "Setup Node.js $NODE_VERSION"
|
||||
fi
|
||||
|
||||
# Clean up any legacy nvm installations
|
||||
if [[ -d "$HOME/.nvm" ]]; then
|
||||
msg_info "Removing legacy nvm installation"
|
||||
rm -rf "$HOME/.nvm" "$HOME/.npm" "$HOME/.bower" "$HOME/.config/yarn" 2>/dev/null || true
|
||||
sed -i '/NVM_DIR/d' "$HOME/.bashrc" "$HOME/.profile" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
ensure_dependencies curl ca-certificates gnupg
|
||||
|
||||
# Clean up ALL old NodeSource repository configurations to avoid conflicts
|
||||
rm -f /etc/apt/sources.list.d/nodesource.list \
|
||||
/etc/apt/sources.list.d/nodesource.sources \
|
||||
/usr/share/keyrings/nodesource.gpg \
|
||||
/etc/apt/keyrings/nodesource.gpg 2>/dev/null || true
|
||||
|
||||
# Setup repository
|
||||
manage_tool_repository "nodejs" "$NODE_VERSION" "https://deb.nodesource.com/node_${NODE_VERSION}.x" "https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key" || {
|
||||
msg_error "Failed to setup Node.js repository"
|
||||
@ -3122,11 +3135,27 @@ function setup_nodejs() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Update to latest npm
|
||||
$STD npm install -g npm@latest || {
|
||||
msg_error "Failed to update npm to latest version"
|
||||
# Verify Node.js was installed correctly
|
||||
if ! command -v node >/dev/null 2>&1; then
|
||||
msg_error "Node.js binary not found after installation"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local INSTALLED_NODE_VERSION
|
||||
INSTALLED_NODE_VERSION=$(node -v 2>/dev/null | grep -oP '^v\K[0-9]+' || echo "0")
|
||||
if [[ "$INSTALLED_NODE_VERSION" != "$NODE_VERSION" ]]; then
|
||||
msg_error "Node.js version mismatch: expected $NODE_VERSION, got $INSTALLED_NODE_VERSION"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Update to latest npm (with version check to avoid incompatibility)
|
||||
local NPM_VERSION
|
||||
NPM_VERSION=$(npm -v 2>/dev/null || echo "0")
|
||||
if [[ "$NPM_VERSION" != "0" ]]; then
|
||||
$STD npm install -g npm@latest 2>/dev/null || {
|
||||
msg_warn "Failed to update npm to latest version (continuing with bundled npm $NPM_VERSION)"
|
||||
}
|
||||
fi
|
||||
|
||||
cache_installed_version "nodejs" "$NODE_VERSION"
|
||||
msg_ok "Setup Node.js $NODE_VERSION"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user