Skip to content

Commit aef869a

Browse files
authored
Merge pull request #449 from tstoeckler/string-path
Allow a single installer path to be declared as a string
2 parents cf056bb + 6e7c999 commit aef869a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Composer/Installers/BaseInstaller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ protected function templatePath($path, array $vars = array())
126126
protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL)
127127
{
128128
foreach ($paths as $path => $names) {
129+
$names = (array) $names;
129130
if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) {
130131
return $path;
131132
}

tests/Composer/Installers/Test/InstallerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,23 @@ public function testVendorPath()
553553
$this->assertEquals('modules/custom/my_module/', $result);
554554
}
555555

556+
/**
557+
* testStringPath
558+
*/
559+
public function testStringPath()
560+
{
561+
$installer = new Installer($this->io, $this->composer);
562+
$package = new Package('penyaskito/my_module', '1.0.0', '1.0.0');
563+
$package->setType('drupal-module');
564+
$this->composer->getPackage()->setExtra(array(
565+
'installer-paths' => array(
566+
'modules/custom/{$name}/' => 'vendor:penyaskito',
567+
),
568+
));
569+
$result = $installer->getInstallPath($package);
570+
$this->assertEquals('modules/custom/my_module/', $result);
571+
}
572+
556573
/**
557574
* testNoVendorName
558575
*/

0 commit comments

Comments
 (0)