Skip to content

Commit 859ff20

Browse files
Revert "fix(installer): remove vendor from target path"
This reverts commit 4b20762.
1 parent 4b20762 commit 859ff20

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
This package is a fork of [Laravel Module Installer](https://github.com/joshbrw/laravel-module-installer) to work with Theme packages.
66
It allows installation of standalone Theme package into the `themes/` directory instead of `vendor/`.
77

8-
For example if your Theme package name is `hexadog/admin-theme` then the package will be installed into `themes/admin` directory.
8+
For example if your Theme package name is `hexadog/admin-theme` then the package will be installed into `themes/hexadog/admin` directory.
99

10-
You can specify an alternate directory by including a `theme-dir` in the extra data in your root application's composer.json file:
10+
You can specify an alternate directory by including a `theme-dir` in the extra data in your composer.json file:
1111

1212
"extra": {
1313
"theme-dir": "custom"

src/ThemeInstaller.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,36 @@ public function getInstallPath(PackageInterface $package)
2424
}
2525

2626
/**
27-
* Get the base path that the theme should be installed into.
28-
* Defaults to themes/ and can be overridden in the root project's composer.json.
27+
* Get the base path that the module should be installed into.
28+
* Defaults to Modules/ and can be overridden in the module's composer.json.
2929
* @return string
3030
*/
3131
protected function getBaseInstallationPath()
3232
{
33-
if ($this->composer && $this->composer->getPackage()) {
34-
$extra = $this->composer->getPackage()->getExtra();
33+
if (!$this->composer || !$this->composer->getPackage()) {
34+
return 'themes';
35+
}
36+
37+
$extra = $this->composer->getPackage()->getExtra();
3538

36-
if (array_key_exists('theme-dir', $extra)) {
37-
return $extra['theme-dir'];
38-
}
39+
if (!$extra || empty($extra['theme-dir'])) {
40+
return 'themes';
3941
}
4042

41-
return 'themes';
43+
return $extra['theme-dir'];
4244
}
4345

4446
/**
4547
* Get the theme name
4648
* "something" => "something"
4749
* "vendor-name/something" => "something"
4850
* "vendor-name/something-theme" => "something"
49-
*
5051
* @param PackageInterface $package
51-
*
5252
* @return string
53+
* @throws \Exception
5354
*/
5455
protected function getThemeName(PackageInterface $package)
5556
{
56-
$name = $package->getPrettyName();
57-
58-
if (($pos = strpos('/', $name)) !== false) {
59-
$name = substr($name, 0, $pos + 1);
60-
}
61-
6257
return str_replace('-theme', '', str_replace('theme-', '', $package->getPrettyName()));
6358
}
6459
}

0 commit comments

Comments
 (0)