Skip to content

Commit b52e75e

Browse files
committed
refactor(env): use lowercase var for root dir and improve venv activation
Refactored .source.dev to use a lowercase variable name for the root directory path for consistency with shell conventions. Improved the Poetry virtual environment activation by sourcing the activate script directly. No functional changes to environment setup logic.
1 parent 0810534 commit b52e75e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

.source.dev

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
# export GITHUB_TOKEN=ghp_....
1717
INSTANCE_NUM="${INSTANCE_NUM:-0}"
1818

19-
_ROOT_DIR_CNT="$(readlink -m "${BASH_SOURCE[0]}/..")"
19+
_root_dir_cnt="$(readlink -m "${BASH_SOURCE[0]}/..")"
2020

2121
# Activate poetry virtual environment
2222
if [ -z "${VIRTUAL_ENV:-}" ]; then
23-
# shellcheck disable=SC2091
24-
$(poetry env activate)
23+
# shellcheck disable=SC2046,SC1091
24+
source $(poetry env info --path)/bin/activate
2525
fi
2626

2727
# Filter out nix python packages from PYTHONPATH.
@@ -41,9 +41,9 @@ unset BOOTSTRAP_DIR
4141
mkdir -p "${CARDANO_NODE_SOCKET_PATH%/*}"
4242

4343
# Set temporary directory for this instance
44-
TMPDIR="$_ROOT_DIR_CNT/tmp"
44+
TMPDIR="$_root_dir_cnt/tmp"
4545
if [ "$INSTANCE_NUM" != 0 ]; then
46-
TMPDIR="$_ROOT_DIR_CNT/tmp${INSTANCE_NUM}"
46+
TMPDIR="$_root_dir_cnt/tmp${INSTANCE_NUM}"
4747
fi
4848
mkdir -p "$TMPDIR"
4949
export TMPDIR
@@ -53,16 +53,16 @@ PATH="$(echo "$PATH" | tr ":" "\n" | grep -v "ghcup" | tr "\n" ":" | sed 's/:*$/
5353
export PATH
5454

5555
# Prepend instance-specific .bin directory to PATH if it exists and if not already present
56-
if [ -e "$_ROOT_DIR_CNT/.bin${INSTANCE_NUM}" ] \
57-
&& [[ ":$PATH:" != *":$_ROOT_DIR_CNT/.bin${INSTANCE_NUM}:"* ]]; then
58-
export PATH="$_ROOT_DIR_CNT/.bin${INSTANCE_NUM}:$PATH"
56+
if [ -e "$_root_dir_cnt/.bin${INSTANCE_NUM}" ] \
57+
&& [[ ":$PATH:" != *":$_root_dir_cnt/.bin${INSTANCE_NUM}:"* ]]; then
58+
export PATH="$_root_dir_cnt/.bin${INSTANCE_NUM}:$PATH"
5959
fi
6060

6161
# Prepend default .bin directory to PATH for instance 0 if it exists and if not already present
6262
if [ "$INSTANCE_NUM" = 0 ] \
63-
&& [ -e "$_ROOT_DIR_CNT/.bin" ] \
64-
&& [[ ":$PATH:" != *":$_ROOT_DIR_CNT/.bin:"* ]]; then
65-
export PATH="$_ROOT_DIR_CNT/.bin:$PATH"
63+
&& [ -e "$_root_dir_cnt/.bin" ] \
64+
&& [[ ":$PATH:" != *":$_root_dir_cnt/.bin:"* ]]; then
65+
export PATH="$_root_dir_cnt/.bin:$PATH"
6666
fi
6767

6868
# Set database connection environment variables for db-sync
@@ -73,7 +73,7 @@ if [ -n "${DBSYNC_SCHEMA_DIR:-}" ] && command -v cardano-smash-server >/dev/null
7373
export SMASH=true
7474
fi
7575

76-
unset INSTANCE_NUM _ROOT_DIR_CNT
76+
unset INSTANCE_NUM _root_dir_cnt
7777

7878
# Enable cardano-cli bash completion
7979
if ! command -v _cardano-cli >/dev/null 2>&1 && command -v cardano-cli >/dev/null 2>&1; then

0 commit comments

Comments
 (0)