Repository navigation
Expand file tree
/
Copy pathget-node.sh
More file actions
81 lines (59 loc) · 2.2 KB
/
Copy pathget-node.sh
File metadata and controls
81 lines (59 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
set -eu
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
die() {
printf '\n%b\n' "${RED}${BOLD}✖ Error:${NC} $1" >&2
exit "${2:-1}"
}
command -v curl >/dev/null 2>&1 ||
die "curl is required but was not found."
VOLTA_HOME="${VOLTA_HOME:-$HOME/.volta}"
BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"
export VOLTA_HOME
export BUN_INSTALL
export PATH="$VOLTA_HOME/bin:$BUN_INSTALL/bin:$PATH"
clear
printf '%b\n' "${CYAN}${BOLD}⚙ Setting up JavaScript tooling...${NC}"
# Reinstall Volta if its installation exists.
if [ -d "$VOLTA_HOME" ]; then
printf '%b\n' "${YELLOW}↻ Existing Volta found — removing it...${NC}"
rm -rf "$VOLTA_HOME"
fi
# Install a clean copy of Volta.
printf '%b\n' "${GREEN}↓ Installing Volta...${NC}"
if ! curl --proto '=https' --tlsv1.2 -sSf https://get.volta.sh | bash; then
die "Volta installation failed."
fi
export PATH="$VOLTA_HOME/bin:$BUN_INSTALL/bin:$PATH"
command -v volta >/dev/null 2>&1 ||
die "Volta installed but could not be found at $VOLTA_HOME/bin/volta."
# Install the current Node release and Yarn through Volta.
printf '%b\n' "${GREEN}↓ Installing Node.js and Yarn with Volta...${NC}"
if ! volta install node yarn >/dev/null 2>&1; then
die "Node.js or Yarn installation failed."
fi
# Reinstall Bun if its standard installation directory already exists.
if [ -d "$BUN_INSTALL" ]; then
printf '%b\n' "${YELLOW}↻ Existing Bun found — removing it...${NC}"
rm -rf "$BUN_INSTALL"
fi
printf '%b\n' "${GREEN}↓ Installing Bun...${NC}"
if ! curl --proto '=https' --tlsv1.2 -fsSL https://bun.com/install | bash >/dev/null 2>&1; then
die "Bun installation failed."
fi
export PATH="$VOLTA_HOME/bin:$BUN_INSTALL/bin:$PATH"
command -v bun >/dev/null 2>&1 ||
die "Bun installed but could not be found at $BUN_INSTALL/bin/bun."
# Clear installation output and show one clean status line.
clear
printf '%b\n' \
"${GREEN}${BOLD}✓ Toolchain ready${NC} " \
"${CYAN}⚡ Volta ${BOLD}$(volta --version)${NC} " \
"${GREEN}⬢ Node ${BOLD}$(node --version)${NC} " \
"${YELLOW}🧶 Yarn ${BOLD}$(yarn --version)${NC} " \
"${RED}🥟 Bun ${BOLD}$(bun --version)${NC}"