Skip to content

Commit 7178398

Browse files
committed
chore: wip
1 parent 0a44bd6 commit 7178398

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

packages/launchpad/src/dev/shellcode.ts

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -599,17 +599,16 @@ __launchpad_chpwd() {
599599
fi
600600
601601
# Compute environment directory with dependency hash
602-
local project_basename
603-
project_basename=$(basename "$real_project_dir")
604-
local md5hash
605-
# Use launchpad's built-in MD5 computation for project path
606-
md5hash=$(printf "%s" "$real_project_dir" | ${launchpadBinary} dev:md5 /dev/stdin 2>/dev/null || echo "00000000")
607-
local project_hash="${project_basename}_$(echo "$md5hash" | cut -c1-8)"
608-
local env_dir="$HOME/.local/share/launchpad/envs/$project_hash"
602+
local project_basename md5hash project_hash env_dir
603+
project_basename=$(basename "$real_project_dir")
604+
# Use launchpad's built-in MD5 computation for project path
605+
md5hash=$(printf "%s" "$real_project_dir" | ${launchpadBinary} dev:md5 /dev/stdin 2>/dev/null || echo "00000000")
606+
project_hash="\${project_basename}_$(echo "$md5hash" | cut -c1-8)"
607+
env_dir="$HOME/.local/share/launchpad/envs/$project_hash"
609608
610609
# Add dependency hash suffix if we have dependencies
611610
if [[ -n "$dep_short" ]]; then
612-
env_dir="${env_dir}-d${dep_short}"
611+
env_dir="\${env_dir}-d\${dep_short}"
613612
fi
614613
615614
if [[ "$LAUNCHPAD_VERBOSE" == "true" ]]; then
@@ -845,23 +844,15 @@ __launchpad_chpwd() {
845844
local dep_file="$(__launchpad_find_dependency_file_path "$real_project_dir" 2>/dev/null)"
846845
847846
if [[ -n "$dep_file" && -f "$dep_file" ]]; then
848-
# Check if the current environment directory matches the expected one for current deps
849-
local expected_dep_md5 expected_dep_short expected_env_dir
850-
expected_dep_md5=$(${launchpadBinary} dev:md5 "$dep_file" 2>/dev/null || echo "")
851-
852-
if [[ -n "$expected_dep_md5" ]]; then
853-
expected_dep_short="$expected_dep_md5" # Already truncated to 8 chars
854-
expected_env_dir="$HOME/.local/share/launchpad/envs/\\${project_basename}_$(echo "$md5hash" | cut -c1-8)-d\\${expected_dep_short}"
855-
856-
# If current environment doesn't match expected environment, dependencies changed
857-
if [[ "$env_dir" != "$expected_env_dir" ]]; then
858-
deps_changed=1
859-
if [[ "$LAUNCHPAD_VERBOSE" == "true" ]]; then
860-
__lp_current_time=$(__lp_get_time_s)
861-
printf "⏱️ [%ss] Dependencies changed (env mismatch), need reinstall\n" $(__lp_elapsed_s "$__lp_start_time" "$__lp_current_time") >&2
862-
printf "🔍 Current: %s\n" "$env_dir" >&2
863-
printf "🔍 Expected: %s\n" "$expected_env_dir" >&2
864-
fi
847+
# Simple check: if we're not in the expected environment directory, dependencies changed
848+
# The expected environment directory is already computed as $env_dir
849+
if [[ "$env_dir" != "$(dirname "$(dirname "$LAUNCHPAD_ENV_BIN_PATH")")" ]]; then
850+
deps_changed=1
851+
if [[ "$LAUNCHPAD_VERBOSE" == "true" ]]; then
852+
__lp_current_time=$(__lp_get_time_s)
853+
printf "⏱️ [%ss] Dependencies changed (env mismatch), need reinstall\n" $(__lp_elapsed_s "$__lp_start_time" "$__lp_current_time") >&2
854+
printf "🔍 Current: %s\n" "$(dirname "$(dirname "$LAUNCHPAD_ENV_BIN_PATH")")" >&2
855+
printf "🔍 Expected: %s\n" "$env_dir" >&2
865856
fi
866857
fi
867858
fi

0 commit comments

Comments
 (0)