1
0
Fork 0

Update cache dir on macOS to follow OS guidelines (now $HOME/Library/Caches/Composer) (#9898)

Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
pull/9928/head
Abi أب 2021-05-28 04:07:23 +07:00 committed by GitHub
parent dd625669e8
commit 759897e7e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -213,9 +213,10 @@ versions. See also [COMPOSER_HOME](03-cli.md#composer-home).
## cache-dir ## cache-dir
Defaults to `C:\Users\<user>\AppData\Local\Composer` on Windows, Defaults to `C:\Users\<user>\AppData\Local\Composer` on Windows,
`$XDG_CACHE_HOME/composer` on unix systems that follow the XDG Base Directory `/Users/<user>/Library/Caches/composer` on macOS, `$XDG_CACHE_HOME/composer`
Specifications, and `$home/cache` on other unix systems. Stores all the caches on unix systems that follow the XDG Base Directory Specifications, and
used by Composer. See also [COMPOSER_HOME](03-cli.md#composer-home). `$home/cache` on other unix systems. Stores all the caches used by Composer.
See also [COMPOSER_HOME](03-cli.md#composer-home).
## cache-files-dir ## cache-files-dir

View File

@ -121,6 +121,15 @@ class Factory
} }
$userDir = self::getUserDir(); $userDir = self::getUserDir();
if (PHP_OS === 'Darwin') {
// Migrate existing cache dir in old location if present
if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) {
Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer');
}
return $userDir . '/Library/Caches/composer';
}
if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) { if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
return $home . '/cache'; return $home . '/cache';
} }