mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:15:07 +00:00
fix(dev): normalize npm cache paths and add maven function guard
- Normalize npm cache paths with pwd -P to handle symlinks and trailing slashes, preventing duplicate scans of same directory - Add declare -f check before calling clean_maven_repository for robustness when dynamic source fails - Add test for trailing slash handling Addresses: dev.sh (line 27, 48, 602)
This commit is contained in:
@@ -133,6 +133,32 @@ EOF
|
||||
[[ "$output" != *"(custom path)"* ]]
|
||||
}
|
||||
|
||||
@test "clean_dev_npm treats default cache path with trailing slash as same path" {
|
||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||
set -euo pipefail
|
||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||
source "$PROJECT_ROOT/lib/clean/dev.sh"
|
||||
start_section_spinner() { :; }
|
||||
stop_section_spinner() { :; }
|
||||
clean_tool_cache() { :; }
|
||||
safe_clean() { echo "$2|$1"; }
|
||||
note_activity() { :; }
|
||||
run_with_timeout() { shift; "$@"; }
|
||||
npm() {
|
||||
if [[ "$1" == "config" && "$2" == "get" && "$3" == "cache" ]]; then
|
||||
echo "$HOME/.npm/"
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
clean_dev_npm
|
||||
EOF
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"npm cache directory|$HOME/.npm/_cacache/*"* ]]
|
||||
[[ "$output" != *"(custom path)"* ]]
|
||||
}
|
||||
|
||||
@test "clean_dev_docker skips when daemon not running" {
|
||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" MO_DEBUG=1 DRY_RUN=false bash --noprofile --norc <<'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
Reference in New Issue
Block a user