Skip to content

feat(clean): align Composer cache cleanup with documented cache-dir resolution#638

Open
MASNathan wants to merge 2 commits intotw93:mainfrom
MASNathan:fix_composer_cleanup
Open

feat(clean): align Composer cache cleanup with documented cache-dir resolution#638
MASNathan wants to merge 2 commits intotw93:mainfrom
MASNathan:fix_composer_cleanup

Conversation

@MASNathan
Copy link

Summary

  • Update Composer cache cleanup to follow Composer's documented cache-dir resolution order from the official docs:
    • Windows: %LOCALAPPDATA%/Composer
    • macOS: ~/Library/Caches/composer
    • XDG Unix: $XDG_CACHE_HOME/composer
    • Other Unix: $COMPOSER_HOME/cache (and existing ~/.composer/cache compatibility)

Why

Composer uses a single effective cache directory based on environment and platform. Cleaning multiple potential paths is unnecessary and can introduce noise/risk. This change makes Mole's behavior deterministic and consistent with Composer docs:
https://getcomposer.org/doc/06-config.md#cache-dir

Tests

  • Validation run:
    • bats tests/clean_dev_caches.bats
    • bash -n lib/clean/dev.sh
    • shellcheck lib/clean/dev.sh tests/clean_dev_caches.bats
Implement a dedicated clean_composer_cache function that checks multiple possible cache locations in a defined priority order: 1. $HOME/.composer/cache (legacy) 2. $HOME/Library/Caches/composer (macOS) 3. XDG_CACHE_HOME/composer (XDG standard) 4. COMPOSER_HOME/cache (Composer-specific) 5. LOCALAPPDATA/Composer (Windows) This ensures proper cache cleanup across different platforms and Composer configurations while maintaining backward compatibility.
@MASNathan MASNathan requested a review from tw93 as a code owner March 24, 2026 18:05
@MASNathan MASNathan changed the title Align Composer cache cleanup with documented cache-dir resolution feat(clean): align Composer cache cleanup with documented cache-dir resolution Mar 24, 2026
Remove complex multi-path detection for Composer cache and replace with explicit cleaning of two known paths. Update whitelist entry to distinguish legacy and current cache locations. Adjust tests to reflect new behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant