forked from dollarshaveclub/es-check
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsetup.sh
executable file
·47 lines (40 loc) · 1.21 KB
/
setup.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
#!/bin/sh
if [ ! -f .env ]; then
cp .env_starter .env
echo "created .env file from .env_starter"
export $(grep -v '^#' .env | xargs)
else
export $(grep -v '^#' .env | xargs)
fi
# Get .env variables
[ ! -f .env ] || export $(grep -v '^#' .env | xargs)
# Check to see if Homebrew, Go, and Pre-commit are installed, and install it if it is not
HAS_NVM=$(command -v nvm >/dev/null)
HAS_PNPM=$(command -v pnpm >/dev/null)
if $HAS_NVM; then
. ~/.nvm/nvm.sh install
else
echo "Please install NVM or ensure your version matches the .nvmrc file"
exit 1
fi
PNPM_MSG="Please install PNPM or ensure your version matches the pnpm version within the .env file"
# load pnpm
if $HAS_PNPM; then
PNPM_LOADED_VERSION=$(command pnpm --version)
if [ "$PNPM_LOADED_VERSION" != "$PNPM_VERSION" ]; then
read -r -p "pnpm versions are out of snyc. Run 'npm install -g pnpm@${PNPM_VERSION}'? [Y/n]" response
response=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [ $response = "y" ] || [ -z $response ]; then
npm install -g pnpm@$PNPM_VERSION
echo 'pnpm version updated globally'
else
echo $PNPM_MSG
exit 1
fi;
else
echo "pnpm version is up-to-date"
fi
else
echo $PNPM_MSG
exit 1
fi