-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy path.envrc
52 lines (40 loc) · 1.45 KB
/
.envrc
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
echo "Starting environment loading…"
START_TIME_MS=$(perl -MTime::HiRes=time -e 'printf "%.0f\n", time * 1000')
# hide warnings from direnv
# see https://github.com/direnv/direnv/issues/419#issuecomment-442005962
# see: https://direnv.net/man/direnv.toml.1.html#codewarntimeoutcode
export DIRENV_WARN_TIMEOUT=876000h # 100 years in hours
export DO_NOT_TRACK=1
# if using nixos, run `use flake`
if has nix; then
use flake
else
# fnm
export FNM_PATH="$HOME/Library/Application Support/fnm"
# Check if fnm is installed, install if not
if ! command -v fnm &> /dev/null || [ -d "$FNM_PATH" ]; then
echo "fnm is not installed. Installing fnm…"
curl -fsSL https://fnm.vercel.app/install | bash -s -- --skip-shell
else
echo "fnm is already installed."
fi
# ensure fnm is in the path
export PATH="$FNM_PATH:$PATH"
# load fnm
eval "`fnm env`"
# install node version from .nvmrc
fnm install
# update to latest corepack
yes | npm update --global corepack npm
# enable pnpm in corepack
yes | corepack enable pnpm
# install package manager with corepack (from package.json#packageManager)
yes | corepack install
fi
# install dependencies
pnpm install
pnpm_version=$(pnpm --version)
echo -e "\nEnvironment is ready.\nUsing pnpm version: $pnpm_version\n"
END_TIME_MS=$(perl -MTime::HiRes=time -e 'printf "%.0f\n", time * 1000')
ELAPSED_TIME=$(bc <<< "scale=3; ($END_TIME_MS - $START_TIME_MS) / 1000")
echo -e "direnv environment setup took $ELAPSED_TIME s.\n"