Repository navigation
Expand file tree
/
Copy pathnvs_node_installer.sh
More file actions
executable file
·77 lines (63 loc) · 2.2 KB
/
Copy pathnvs_node_installer.sh
File metadata and controls
executable file
·77 lines (63 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
#!/usr/bin/env bash
# Load custom functions
if type 'colorEcho' 2>/dev/null | grep -q 'function'; then
:
else
if [[ -s "${MY_SHELL_SCRIPTS:-$HOME/.dotfiles}/custom_functions.sh" ]]; then
source "${MY_SHELL_SCRIPTS:-$HOME/.dotfiles}/custom_functions.sh"
else
echo "${MY_SHELL_SCRIPTS:-$HOME/.dotfiles}/custom_functions.sh does not exist!"
exit 0
fi
fi
# Use proxy or mirror when some sites were blocked or low speed
[[ -z "${THE_WORLD_BLOCKED}" ]] && set_proxy_mirrors_env
colorEcho "${BLUE}Installing ${FUCHSIA}nvs & nodejs${BLUE}..."
## Install nvs
# https://github.com/jasongin/nvs
if [[ ! -d "$HOME/.nvs" ]]; then
export NVS_HOME="$HOME/.nvs"
git clone https://github.com/jasongin/nvs --depth=1 "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
fi
if [[ -d "$HOME/.nvs" ]]; then
if type 'nvs' 2>/dev/null | grep -q 'function'; then
:
else
export NVS_HOME="$HOME/.nvs"
[ -s "$NVS_HOME/nvs.sh" ] && . "$NVS_HOME/nvs.sh"
fi
if [[ "${THE_WORLD_BLOCKED}" == "true" ]]; then
nvs remote node "${NVS_NODEJS_ORG_MIRROR:-"https://npmmirror.com/mirrors/node"}"
fi
fi
## Install nodejs
if type 'nvs' 2>/dev/null | grep -q 'function'; then
if [[ ! "$(command -v node)" ]]; then
colorEcho "${BLUE}Installing ${FUCHSIA}node LTS${BLUE}..."
nvs add lts
colorEcho "${BLUE}Installing ${FUCHSIA}node latest${BLUE}..."
nvs add latest
# nvs use latest
# nvs link latest
nvs use lts
nvs link lts
fi
fi
if [[ -x "$(command -v npm)" ]]; then
[[ -s "${MY_SHELL_SCRIPTS:-$HOME/.dotfiles}/nodejs/npm_config.sh" ]] && \
source "${MY_SHELL_SCRIPTS:-$HOME/.dotfiles}/nodejs/npm_config.sh"
if [[ ! -x "$(command -v npm-check)" ]]; then
colorEcho "${BLUE}Installing ${FUCHSIA}npm-check${BLUE}..."
npm install -g npm-check
fi
if [[ ! -x "$(command -v pm2)" ]]; then
colorEcho "${BLUE}Installing ${FUCHSIA}pm2${BLUE}..."
npm install -g pm2
fi
if [[ ! -x "$(command -v pnpm)" ]]; then
colorEcho "${BLUE}Installing ${FUCHSIA}pnpm${BLUE}..."
# npm install -g pnpm
curl -fsSL https://get.pnpm.io/install.sh | sh -
fi
fi