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
parent
dd625669e8
commit
759897e7e8
|
@ -213,9 +213,10 @@ versions. See also [COMPOSER_HOME](03-cli.md#composer-home).
|
|||
## cache-dir
|
||||
|
||||
Defaults to `C:\Users\<user>\AppData\Local\Composer` on Windows,
|
||||
`$XDG_CACHE_HOME/composer` on unix systems that follow the XDG Base Directory
|
||||
Specifications, and `$home/cache` on other unix systems. Stores all the caches
|
||||
used by Composer. See also [COMPOSER_HOME](03-cli.md#composer-home).
|
||||
`/Users/<user>/Library/Caches/composer` on macOS, `$XDG_CACHE_HOME/composer`
|
||||
on unix systems that follow the XDG Base Directory Specifications, and
|
||||
`$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
|
||||
|
||||
|
|
|
@ -121,6 +121,15 @@ class Factory
|
|||
}
|
||||
|
||||
$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')) {
|
||||
return $home . '/cache';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue