-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.envrc
More file actions
62 lines (51 loc) · 1.86 KB
/
.envrc
File metadata and controls
62 lines (51 loc) · 1.86 KB
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
# code: language=shellscript insertSpaces=true tabSize=2
# shellcheck disable=SC2148
# https://direnv.net/man/direnv-stdlib.1.html
dotenv_if_exists
layout node
source_env_if_exists .envrc.project
if test -f 'package.json' && test -z "${NODE_NO_INSTALL_PACKAGES:-}"; then
watch_file 'package.json'
if ! test -d 'node_modules' || test 'node_modules/.package.json' -ot 'package.json'; then
if test -z "${NODE_PACKAGE_MANAGER:-}"; then
if test -f 'yarn.lock'; then
echo 'Installing dependencies using yarn...'
yarn install
elif test -f 'package-lock.json'; then
echo 'Installing dependencies using npm...'
npm install
else
echo 'No supported lock file found. Installing dependencies using yarn...'
yarn install
fi
else
echo "Installing dependencies with ${NODE_PACKAGE_MANAGER}..."
$NODE_PACKAGE_MANAGER install
fi
touch 'node_modules/.package.json'
fi
fi
if test -f "${PWD}/.pre-commit-config.yml" && ! test -f "${PWD}/.venv/.pre-commit-installed"; then
if test -z "${PYTHON_VERSION:-}" && test -f "${PWD}/.python-version"; then
PYTHON_VERSION=$(head -n 1 "${PWD}/.python-version")
fi
if test -z "${PYTHON_VERSION:-}"; then
PYTHON_VERSION=$(semver_search /usr/lib python 3)
fi
if test -z "${PYTHON_VERSION:-}"; then
echo "-> No Python version found. Please create a .python-version file or set PYTHON_VERSION in your environment." >&2
exit 1
fi
export VIRTUAL_ENV="${PWD}/.venv"
layout python "python${PYTHON_VERSION}"
echo '*' > "${PWD}/.venv/.gitignore"
if ! test -f "${PWD}/.venv/.pip-updated"; then
pip install --upgrade pip
touch "${PWD}/.venv/.pip-updated"
fi
if test -z "$(pip list 2>/dev/null | grep -oE 'pre[-_]commit')"; then
pip install pre-commit
fi
pre-commit install
touch "${PWD}/.venv/.pre-commit-installed"
fi