Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a single installer path to be declared as a string #449

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Composer/Installers/BaseInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ protected function templatePath($path, array $vars = array())
protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL)
{
foreach ($paths as $path => $names) {
$names = (array) $names;
if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) {
return $path;
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Composer/Installers/Test/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,23 @@ public function testVendorPath()
$this->assertEquals('modules/custom/my_module/', $result);
}

/**
* testStringPath
*/
public function testStringPath()
{
$installer = new Installer($this->io, $this->composer);
$package = new Package('penyaskito/my_module', '1.0.0', '1.0.0');
$package->setType('drupal-module');
$this->composer->getPackage()->setExtra(array(
'installer-paths' => array(
'modules/custom/{$name}/' => 'vendor:penyaskito',
),
));
$result = $installer->getInstallPath($package);
$this->assertEquals('modules/custom/my_module/', $result);
}

/**
* testNoVendorName
*/
Expand Down