1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 15:45:06 +00:00

chore: auto format code

This commit is contained in:
Tw93
2025-12-17 12:36:26 +00:00
parent 34bdd14a6f
commit 611254848d
2 changed files with 30 additions and 30 deletions

View File

@@ -86,13 +86,13 @@ perform_purge() {
# Read stats # Read stats
if [[ -f "$SCRIPT_DIR/../.mole_cleanup_stats" ]]; then if [[ -f "$SCRIPT_DIR/../.mole_cleanup_stats" ]]; then
total_size_cleaned=$(cat "$SCRIPT_DIR/../.mole_cleanup_stats" 2>/dev/null || echo "0") total_size_cleaned=$(cat "$SCRIPT_DIR/../.mole_cleanup_stats" 2> /dev/null || echo "0")
rm -f "$SCRIPT_DIR/../.mole_cleanup_stats" rm -f "$SCRIPT_DIR/../.mole_cleanup_stats"
fi fi
# Read count # Read count
if [[ -f "$SCRIPT_DIR/../.mole_cleanup_count" ]]; then if [[ -f "$SCRIPT_DIR/../.mole_cleanup_count" ]]; then
total_items_cleaned=$(cat "$SCRIPT_DIR/../.mole_cleanup_count" 2>/dev/null || echo "0") total_items_cleaned=$(cat "$SCRIPT_DIR/../.mole_cleanup_count" 2> /dev/null || echo "0")
rm -f "$SCRIPT_DIR/../.mole_cleanup_count" rm -f "$SCRIPT_DIR/../.mole_cleanup_count"
fi fi

View File

@@ -7,19 +7,19 @@ set -euo pipefail
# Targets to look for (heavy build artifacts) # Targets to look for (heavy build artifacts)
readonly PURGE_TARGETS=( readonly PURGE_TARGETS=(
"node_modules" "node_modules"
"target" # Rust, Maven "target" # Rust, Maven
"build" # Gradle, various "build" # Gradle, various
"dist" # JS builds "dist" # JS builds
"venv" # Python "venv" # Python
".venv" # Python ".venv" # Python
".gradle" # Gradle local ".gradle" # Gradle local
"__pycache__" # Python "__pycache__" # Python
".next" # Next.js ".next" # Next.js
".nuxt" # Nuxt.js ".nuxt" # Nuxt.js
".output" # Nuxt.js ".output" # Nuxt.js
"vendor" # PHP Composer "vendor" # PHP Composer
"obj" # C# / Unity "obj" # C# / Unity
".turbo" # Turborepo cache ".turbo" # Turborepo cache
".parcel-cache" # Parcel bundler ".parcel-cache" # Parcel bundler
) )
@@ -97,9 +97,9 @@ scan_purge_targets() {
done done
# Run fd command # Run fd command
fd "${fd_args[@]}" . "$search_path" 2>/dev/null | while IFS= read -r item; do fd "${fd_args[@]}" . "$search_path" 2> /dev/null | while IFS= read -r item; do
if is_safe_project_artifact "$item" "$search_path"; then if is_safe_project_artifact "$item" "$search_path"; then
echo "$item" echo "$item"
fi fi
done | filter_nested_artifacts > "$output_file" done | filter_nested_artifacts > "$output_file"
else else
@@ -112,8 +112,8 @@ scan_purge_targets() {
# 1. Directories to prune (ignore completely) # 1. Directories to prune (ignore completely)
local prune_dirs=(".git" "Library" ".Trash" "Applications") local prune_dirs=(".git" "Library" ".Trash" "Applications")
for dir in "${prune_dirs[@]}"; do for dir in "${prune_dirs[@]}"; do
# -name "DIR" -prune -o # -name "DIR" -prune -o
prune_args+=("-name" "$dir" "-prune" "-o") prune_args+=("-name" "$dir" "-prune" "-o")
done done
# 2. Targets to find (print AND prune) # 2. Targets to find (print AND prune)
@@ -137,7 +137,7 @@ scan_purge_targets() {
# Excludes # Excludes
for dir in "${prune_dirs[@]}"; do for dir in "${prune_dirs[@]}"; do
find_expr+=("-name" "$dir" "-prune" "-o") find_expr+=("-name" "$dir" "-prune" "-o")
done done
# Targets # Targets
@@ -153,7 +153,7 @@ scan_purge_targets() {
done done
command find "$search_path" -mindepth 2 -maxdepth 5 -type d \ command find "$search_path" -mindepth 2 -maxdepth 5 -type d \
\( "${find_expr[@]}" \) 2>/dev/null | while IFS= read -r item; do \( "${find_expr[@]}" \) 2> /dev/null | while IFS= read -r item; do
if is_safe_project_artifact "$item" "$search_path"; then if is_safe_project_artifact "$item" "$search_path"; then
echo "$item" echo "$item"
@@ -195,15 +195,15 @@ is_recently_modified() {
# Check modification time (macOS compatible) # Check modification time (macOS compatible)
local mod_time local mod_time
mod_time=$(stat -f "%m" "$path" 2>/dev/null || stat -c "%Y" "$path" 2>/dev/null || echo "0") mod_time=$(stat -f "%m" "$path" 2> /dev/null || stat -c "%Y" "$path" 2> /dev/null || echo "0")
local current_time=$(date +%s) local current_time=$(date +%s)
local age_seconds=$((current_time - mod_time)) local age_seconds=$((current_time - mod_time))
local age_in_days=$((age_seconds / 86400)) local age_in_days=$((age_seconds / 86400))
if [[ $age_in_days -lt $age_days ]]; then if [[ $age_in_days -lt $age_days ]]; then
return 0 # Recently modified return 0 # Recently modified
else else
return 1 # Old enough to clean return 1 # Old enough to clean
fi fi
} }
@@ -212,7 +212,7 @@ is_recently_modified() {
get_dir_size_kb() { get_dir_size_kb() {
local path="$1" local path="$1"
if [[ -d "$path" ]]; then if [[ -d "$path" ]]; then
du -sk "$path" 2>/dev/null | awk '{print $1}' || echo "0" du -sk "$path" 2> /dev/null | awk '{print $1}' || echo "0"
else else
echo "0" echo "0"
fi fi
@@ -252,12 +252,12 @@ safe_clean() {
local original_prefix="${MOLE_SPINNER_PREFIX:-}" local original_prefix="${MOLE_SPINNER_PREFIX:-}"
MOLE_SPINNER_PREFIX="" start_inline_spinner "Cleaning $description (~${size_mb}MB)..." MOLE_SPINNER_PREFIX="" start_inline_spinner "Cleaning $description (~${size_mb}MB)..."
rm -rf "$path" 2>/dev/null || true rm -rf "$path" 2> /dev/null || true
stop_inline_spinner stop_inline_spinner
MOLE_SPINNER_PREFIX="$original_prefix" MOLE_SPINNER_PREFIX="$original_prefix"
else else
rm -rf "$path" 2>/dev/null || true rm -rf "$path" 2> /dev/null || true
fi fi
if [[ ! -e "$path" ]]; then if [[ ! -e "$path" ]]; then
@@ -326,11 +326,11 @@ clean_project_artifacts() {
cleanup_scan() { cleanup_scan() {
# Kill all background scans # Kill all background scans
for pid in "${scan_pids[@]}"; do for pid in "${scan_pids[@]}"; do
kill "$pid" 2>/dev/null || true kill "$pid" 2> /dev/null || true
done done
# Clean up temp files # Clean up temp files
for temp in "${scan_temps[@]}"; do for temp in "${scan_temps[@]}"; do
rm -f "$temp" 2>/dev/null || true rm -f "$temp" 2> /dev/null || true
done done
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
stop_inline_spinner stop_inline_spinner
@@ -363,7 +363,7 @@ clean_project_artifacts() {
# Wait for all scans to complete # Wait for all scans to complete
for pid in "${scan_pids[@]}"; do for pid in "${scan_pids[@]}"; do
wait "$pid" 2>/dev/null || true wait "$pid" 2> /dev/null || true
done done
if [[ -t 1 ]]; then if [[ -t 1 ]]; then