Fix removal of packages installed in custom path with custom installers not overriding uninstall, fixes #2232

main
Jordi Boggiano 9 years ago
parent 4071b09091
commit d98b134dc3

@ -141,16 +141,33 @@ class LibraryInstaller implements InstallerInterface
*/ */
public function getInstallPath(PackageInterface $package) public function getInstallPath(PackageInterface $package)
{ {
$this->initializeVendorDir();
$basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
$targetDir = $package->getTargetDir(); $targetDir = $package->getTargetDir();
return $this->getPackageBasePath($package) . ($targetDir ? '/'.$targetDir : ''); return $basePath . ($targetDir ? '/'.$targetDir : '');
} }
/**
* Returns the base path of the package without target-dir path
*
* It is used for BC as getInstallPath tends to be overriden by
* installer plugins but not getPackageBasePath
*
* @param PackageInterface $package
* @return string
*/
protected function getPackageBasePath(PackageInterface $package) protected function getPackageBasePath(PackageInterface $package)
{ {
$this->initializeVendorDir(); $installPath = $this->getInstallPath($package);
$targetDir = $package->getTargetDir();
if ($targetDir) {
return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
}
return ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName(); return $installPath;
} }
protected function installCode(PackageInterface $package) protected function installCode(PackageInterface $package)

Loading…
Cancel
Save