Skip to content

Commit

Permalink
Allow a single installer path to be declared as a string
Browse files Browse the repository at this point in the history
  • Loading branch information
tstoeckler committed Mar 6, 2020
1 parent 7d610d5 commit 6e7c999
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit 6e7c999

Please sign in to comment.