From 08c4732d1ed88745e844c383f0526f65aa67fb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kocsis=20M=C3=A1t=C3=A9?= Date: Tue, 3 Feb 2015 19:27:29 +0100 Subject: [PATCH] Improving bin-compat configuration --- src/Composer/Config.php | 12 ++++++++++++ src/Composer/Installer/LibraryInstaller.php | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Composer/Config.php b/src/Composer/Config.php index b6d942c51..b4e1c38c2 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -29,6 +29,7 @@ class Config 'github-protocols' => array('git', 'https', 'ssh'), 'vendor-dir' => 'vendor', 'bin-dir' => '{$vendor-dir}/bin', + 'bin-compat' => 'auto', 'cache-dir' => '{$home}/cache', 'cache-files-dir' => '{$cache-dir}/files', 'cache-repo-dir' => '{$cache-dir}/repo', @@ -215,6 +216,17 @@ class Config case 'home': return rtrim($this->process($this->config[$key], $flags), '/\\'); + case 'bin-compat': + $value= $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key]; + + if (!in_array($value, array('auto', 'nosymlink', 'full'))) { + throw new \RuntimeException( + "Invalid value for 'bin-compat': {$value}. Expected auto, nosymlink, full" + ); + } + + return $value; + case 'discard-changes': if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) { if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) { diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index a4c902286..4f0900a01 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -54,7 +54,7 @@ class LibraryInstaller implements InstallerInterface $this->filesystem = $filesystem ?: new Filesystem(); $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/'); $this->binDir = rtrim($composer->getConfig()->get('bin-dir'), '/'); - $this->binCompat = trim(getenv("COMPOSER_BIN_COMPAT")) ?: 'auto'; + $this->binCompat = $composer->getConfig()->get('bin-compat'); } /** @@ -227,9 +227,9 @@ class LibraryInstaller implements InstallerInterface } else { $this->installSymlinkBinaries($binPath, $link); } - } elseif($this->binCompat === "nosymlink") { + } elseif ($this->binCompat === "nosymlink") { $this->installUnixyProxyBinaries($binPath, $link); - } elseif($this->binCompat === "full") { + } elseif ($this->binCompat === "full") { $this->installFullBinaries($binPath, $link, $bin, $package); } @chmod($link, 0777 & ~umask());