Skip to content

Commit 0712a69

Browse files
committed
Update tools.func
1 parent 0557417 commit 0712a69

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

misc/tools.func

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,24 @@ function setup_nodejs() {
5454
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_VERSION}.x nodistro main" \
5555
>/etc/apt/sources.list.d/nodesource.list
5656

57+
sleep 2
5758
if ! apt-get update >/dev/null 2>&1; then
58-
msg_error "Failed to update APT repositories after adding NodeSource"
59+
msg_warn "APT update failed – retrying in 5s"
60+
sleep 5
61+
if ! apt-get update >/dev/null 2>&1; then
62+
msg_error "Failed to update APT repositories after adding NodeSource"
63+
exit 1
64+
fi
65+
fi
66+
67+
if ! apt-cache policy nodejs | grep -q 'Candidate:'; then
68+
msg_error "Node.js package not found – repository might be broken or too fresh"
69+
apt-cache policy nodejs >&2
70+
exit 1
71+
fi
72+
73+
if ! apt-get install -y nodejs >/dev/null 2>&1; then
74+
msg_error "Failed to install Node.js ${NODE_VERSION} from NodeSource"
5975
exit 1
6076
fi
6177

0 commit comments

Comments
 (0)