Explorar o código

Throw exception if HOME or APPDATA is not available to create the composer home dir

Jordi Boggiano %!s(int64=12) %!d(string=hai) anos
pai
achega
e8c362c273
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      src/Composer/Factory.php

+ 6 - 0
src/Composer/Factory.php

@@ -43,8 +43,14 @@ class Factory
         $cacheDir = getenv('COMPOSER_CACHE_DIR');
         if (!$home) {
             if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
+                if (!getenv('APPDATA')) {
+                    throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
+                }
                 $home = strtr(getenv('APPDATA'), '\\', '/') . '/Composer';
             } else {
+                if (!getenv('HOME')) {
+                    throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
+                }
                 $home = rtrim(getenv('HOME'), '/') . '/.composer';
             }
         }