Skip to content

Commit ee1b50e

Browse files
committed
direnvrc: remove more unused code
1 parent 9c1879f commit ee1b50e

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

direnvrc

+5-30
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,6 @@ nix_direnv_watch_file() {
8888
watch_file "$@"
8989
}
9090

91-
_nix_direnv_watches() {
92-
local -n _watches=$1
93-
if [[ -z ${DIRENV_WATCHES-} ]]; then
94-
return
95-
fi
96-
while IFS= read -r line; do
97-
local regex='"[Pp]ath": "(.+)"$'
98-
if [[ $line =~ $regex ]]; then
99-
local path="${BASH_REMATCH[1]}"
100-
if [[ $path == "${XDG_DATA_HOME:-${HOME:-/var/empty}/.local/share}/direnv/allow/"* ]]; then
101-
continue
102-
fi
103-
# expand new lines and other json escapes
104-
# shellcheck disable=2059
105-
path=$(printf "$path")
106-
_watches+=("$path")
107-
fi
108-
done < <($direnv show_dump "${DIRENV_WATCHES}")
109-
}
110-
11191
_devenv_watches() {
11292
local path=$1
11393
local -n _watches=$2
@@ -140,20 +120,18 @@ use_devenv() {
140120
fi
141121
fi
142122

143-
# Watch the default files
123+
# Watch the default files.
124+
# Even if evaluation fails, these files should still trigger a reload.
144125
watch_file "${default_watches[@]}"
145126

146127
# Fetch and watch files that affect the env
147128
local env_watches
148129
_devenv_watches "$env_deps_path" env_watches
149130
watch_file "${env_watches[@]}"
150131

151-
# Fetch all files that direnv is currently watching
152-
local watches
153-
_nix_direnv_watches watches
154-
132+
# Build the environment
155133
local env
156-
if ! env=$("${DEVENV_BIN}" print-dev-env --quiet); then
134+
if ! env=$("${DEVENV_BIN}" print-dev-env); then
157135
log_error "failed to build the devenv environment. devenv.nix may contain errors. see above."
158136
exit 0
159137
fi
@@ -163,9 +141,6 @@ use_devenv() {
163141
_devenv_watches "$env_deps_path" env_watches
164142
watch_file "${env_watches[@]}"
165143

166-
# Fetch the final watches
167-
local watches
168-
_nix_direnv_watches watches
169-
144+
# Import the environment
170145
_nix_import_env "$env"
171146
}

0 commit comments

Comments
 (0)