-
Notifications
You must be signed in to change notification settings - Fork 0
/
.envrc
63 lines (49 loc) · 2.38 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
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
# basher installation scheme for dependencies; you can change this if you want,
# so long as all the variables are correct. The .devkit/dk script will clone
# basher to $BASHER_ROOT and look for binaries in $BASHER_INSTALL_BIN.
export BASHER_PREFIX="$PWD/.deps"
export BASHER_INSTALL_BIN="$BASHER_PREFIX/bin"
export BASHER_INSTALL_MAN="$BASHER_PREFIX/man"
# Dependencies are checked out here:
export BASHER_PACKAGES_PATH="$BASHER_PREFIX"
export BASHER_ROOT="$BASHER_PACKAGES_PATH/basherpm/basher"
# Build go-based deps in .deps
export GOPATH="$BASHER_PREFIX/go"
export GOBIN="$BASHER_INSTALL_BIN"
# Stub in case direnv isn't being used
declare -F -- watch_file >/dev/null || watch_file() { :;}
# If these files change, so might our paths, so direnv should reload
watch_file \
"$BASHER_PREFIX/.gimme-env" \
"$BASHER_INSTALL_BIN/activate" \
"$BASHER_INSTALL_BIN/python" \
"$PWD/composer.json" \
"$PWD/package.json" \
"$PWD/.nvmrc"
# Activate nvm if Node project w/.nvmrc (but don't install node)
if [[ -f .nvmrc ]]; then
if ! declare -F -- nvm >/dev/null; then
# No user-level nvm? Install as a project dependency
[[ "${NVM_DIR-}" ]] || export NVM_DIR="$BASHER_PREFIX/nvm-sh/nvm"
[[ -d "${NVM_DIR}" ]] || git clone -q --depth=1 https://github.com/nvm-sh/nvm.git "$NVM_DIR"
source "$NVM_DIR/nvm.sh" --no-use
fi
nvm use || true # Allow failures to proceed anyway
fi
# Activate gimme/go enviornment if Go project
[[ ! -f "$BASHER_PREFIX/.gimme-env" ]] || source "$BASHER_PREFIX/.gimme-env"
# Activate virtualenv if present
[[ -f $BASHER_INSTALL_BIN/activate && -f $BASHER_INSTALL_BIN/python ]] &&
[[ ! "${VIRTUAL_ENV-}" || $VIRTUAL_ENV != "$BASHER_PREFIX" ]] &&
VIRTUAL_ENV_DISABLE_PROMPT=true source $BASHER_INSTALL_BIN/activate
__dk_path() { [[ :"${!1}": == *:"$2":* ]] || export $1="$2:${!1}"; }
# Activate .composer/vendor/bin if PHP project
[[ ! -f composer.json ]] || __dk_path PATH "$PWD/vendor/bin"
# Activate node_modules/.bin if Node project
[[ ! -f package.json ]] || __dk_path PATH "$PWD/node_modules/.bin"
# $BASHER_INSTALL_BIN must be on PATH to use commands installed as deps
__dk_path PATH "$BASHER_INSTALL_BIN"
# You can add other variables you want available via direnv. Configuration
# variables for devkit itself, however, should go in .dkrc unless they need
# to be available via direnv as well.