-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
.envrc
55 lines (47 loc) · 1.46 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
53
54
55
#!/usr/bin/env bash
# This file provides some tooling on an opt-in basis via `direnv`
# (https://direnv.net/)
# To use the functionality here, create an `.envrc.local` file in this folder
# that runs the functions you need.
# There is an example in `.envrc.local.example` you can start with
# `use nvm`
# if `nvm` is installed, use it to select the right node.js version
# as defined in the `.nvmrc` file
use_nvm() {
local NVM_DIR
if [[ -z "${XDG_CONFIG_HOME:-}" ]]; then
NVM_DIR="${HOME}/.nvm"
else
NVM_DIR="${XDG_CONFIG_HOME}/nvm"
fi
if ! [[ -d "$NVM_DIR" ]]; then
echo >&2 "ERROR: nvm not found. Could not set the node.js version."
return 1
fi
# shellcheck source=/dev/null
[[ -s "$NVM_DIR/nvm.sh" ]] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm use
}
# `use ghcup`
# if `ghcup` is available, use it to install and set the GHC version
# as defined in the `.ghcversion` file
use_ghcup() {
local GHC_VERSION GHCUP_PATH
GHC_VERSION="$(<.ghcversion)"
GHCUP_PATH="$(which ghcup)"
if [[ -z "$GHC_VERSION" ]]; then
echo >&2 'ERROR: Required GHC version not found.'
return 1
fi
if [[ -z "$GHCUP_PATH" ]]; then
echo 'ERROR: ghcup not found. Could not set the GHC version.'
return 1
fi
if ! ghcup whereis ghc "$GHC_VERSION" &> /dev/null; then
ghcup install ghc "$GHC_VERSION"
fi
ghcup set ghc "$GHC_VERSION"
}
watch_file server/VERSIONS.json
# this line sources your `.envrc.local` file
source_env_if_exists .envrc.local