From 40baa3ff05adf79a88498bf409e560eb1d13652d Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 19 Jan 2016 10:54:14 +0000 Subject: [PATCH] Use COMPOSER_HOME if defined instead of falling back to HOME, fixes #4789 --- src/Composer/Factory.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index f6537c101..218ec77c2 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -84,6 +84,11 @@ class Factory return $cacheDir; } + $homeEnv = getenv('COMPOSER_HOME'); + if ($homeEnv) { + return $homeEnv . '/cache'; + } + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { if ($cacheDir = getenv('LOCALAPPDATA')) { $cacheDir .= '/Composer'; @@ -114,6 +119,11 @@ class Factory */ protected static function getDataDir($home) { + $homeEnv = getenv('COMPOSER_HOME'); + if ($homeEnv) { + return $homeEnv; + } + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { return strtr($home, '\\', '/'); }