Skip to content

Commit

Permalink
fix: Missing vendor name in install path
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetan-hexadog committed Oct 3, 2020
1 parent aec3bce commit e881826
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 1 addition & 8 deletions src/ThemeInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ protected function getBaseInstallationPath()
*/
protected function getThemeName(PackageInterface $package)
{
$name = $package->getPrettyName();
$split = explode("/", $name);

$splitNameToUse = explode("-", count($split) >= 2 ? $split[1] : $split[0]);

return implode('', array_map('strtolower', array_filter($splitNameToUse, function ($value) {
return $value !== "theme";
})));
return str_replace('-theme', '', str_replace('-theme', '', $package->getPrettyName()));
}
}
10 changes: 5 additions & 5 deletions tests/ThemeInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function it_supports_vendor_not_included()
{
$mock = $this->getMockPackage('name');

$this->assertEquals('themes/Name', $this->test->getInstallPath($mock));
$this->assertEquals('themes/name', $this->test->getInstallPath($mock));
}

/**
Expand All @@ -59,7 +59,7 @@ public function it_supports_vendor_not_included()
public function it_returns_themes_folder_by_default()
{
$mock = $this->getMockPackage('vendor/name-theme');
$this->assertEquals('themes/Name', $this->test->getInstallPath($mock));
$this->assertEquals('themes/vendor/name', $this->test->getInstallPath($mock));
}

/**
Expand All @@ -69,7 +69,7 @@ public function it_can_use_compound_theme_names()
{
$mock = $this->getMockPackage('vendor/compound-name-theme');

$this->assertEquals('themes/CompoundName', $this->test->getInstallPath($mock));
$this->assertEquals('themes/vendor/compound-name', $this->test->getInstallPath($mock));
}

/**
Expand All @@ -87,10 +87,10 @@ public function it_can_use_custom_path()
$package = $this->getMockPackage('vendor/name-theme');

$this->composer->shouldReceive('getExtra')
->andReturn(['theme-dir' => 'Custom'])
->andReturn(['theme-dir' => 'custom'])
->getMock();

$this->assertEquals('Custom/Name', $this->test->getInstallPath($package));
$this->assertEquals('custom/vendor/name', $this->test->getInstallPath($package));
}


Expand Down

0 comments on commit e881826

Please sign in to comment.