-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·58 lines (46 loc) · 1.49 KB
/
install.sh
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
#!/bin/sh
install_wildflower() {
npm ls -g wildflower && {
echo "wildflower already installed. Nothing to do. Exiting…"
} || {
echo "Installing wildflower…"
npm i -g github:echo-bravo-yahoo/wildflower#2.0.0 || {
echo "Failed to install wildflower. Exiting!"
exit 1
}
}
}
NVM_VERSION=""
NODE_VERSION=""
NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
if [ -s "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh" # This loads nvm
NVM_VERSION=$(nvm --version)
fi
NODE_VERSION=$(node --version)
if [[ $NVM_VERSION == "" && $NODE_VERSION != "" ]]; then
echo "Detected node without nvm. Installing wildflower globally. Good luck!"
install_wildflower
else
if [[ $NVM_VERSION == "" ]]; then
echo "Installing nvm…"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
. "$NVM_DIR/nvm.sh"
else
echo "nvm already installed!"
fi
if [[ "$NODE_VERSION" == "" ]]; then
echo "Installing node…"
nvm install 20
else
echo "node already installed!"
fi
install_wildflower
# install a bin in `/usr/local/bin` that points to the version of wildflower we just installed
mkdir -p /usr/local/bin
echo '#!/bin/sh
NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
. "$NVM_DIR/nvm.sh"
nvm exec '"$(node --version)"' wildflower' | sudo tee /usr/local/bin/wildflower > /dev/null
sudo chmod +x /usr/local/bin/wildflower
fi