Skip to content

Commit

Permalink
Fix an issue with missing basePath being treated as an absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
teppokoivula committed Jun 2, 2019
1 parent 7bbc81b commit 03fab10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix an issue where a typo in ModuleInstaller prevented it from working properly.
- Fix an issue with missing basePath being treated as an absolute path.

## [0.0.1] - 2019-06-03

Expand Down
9 changes: 7 additions & 2 deletions src/ComposerInstaller/BaseInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ protected function getBasePath($defaultBasePath) {
$type = strtolower(preg_replace('/(?<!^)[A-Z]/', '-$0', substr($class, 0, strrpos($class, 'Installer'))));
$basePath = $extra['pw-' . $type . '-path'] ?? $defaultBasePath;

// if base path is set, make sure that it has a trailing slash
$basePath = trim($basePath, '/');
if (strlen($basePath)) {
$basePath .= '/';
}

return $basePath;
}

Expand Down Expand Up @@ -89,7 +95,6 @@ protected function getName(PackageInterface $package) {
protected function getFullPath(PackageInterface $package, $defaultBasePath) {
$basePath = $this->getBasePath($defaultBasePath);
$name = $this->getName($package);
$path = trim($basePath, '/') . '/' . $name;
return $path;
return $basePath . $name;
}
}

0 comments on commit 03fab10

Please sign in to comment.