-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
18 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
/config/Migrations/schema-dump-default.lock | ||
/vendor/ | ||
/.idea/ | ||
.DS_Store | ||
.DS_Store | ||
.phpunit.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
namespace ViteHelper\Utilities; | ||
|
||
use Cake\Core\Plugin; | ||
use ViteHelper\Exception\ManifestNotFoundException; | ||
|
||
/** | ||
|
@@ -14,13 +15,17 @@ class ViteManifest | |
* Returns the manifest records as a Collection | ||
* | ||
* @param \ViteHelper\Utilities\ViteHelperConfig $config plugin config instance | ||
* @return \ViteHelper\Utilities\ManifestRecords|\ViteHelper\Utilities\ManifestRecord[] | ||
* @return \ViteHelper\Utilities\ManifestRecords|array<\ViteHelper\Utilities\ManifestRecord> | ||
* @throws \ViteHelper\Exception\ManifestNotFoundException | ||
* @internal | ||
*/ | ||
public static function getRecords(ViteHelperConfig $config): ManifestRecords | ||
Check failure on line 22 in src/Utilities/ViteManifest.php GitHub Actions / Coding Standard & Static Analysis
|
||
{ | ||
$manifestPath = $config->read('build.manifest', ConfigDefaults::BUILD_MANIFEST); | ||
if ($config->read('plugin') && $config->read('build.manifest') === null) { | ||
$manifestPath = static::getPluginManifestPath($config->read('plugin')); | ||
} else { | ||
$manifestPath = $config->read('build.manifest', ConfigDefaults::BUILD_MANIFEST); | ||
} | ||
|
||
if (!is_readable($manifestPath)) { | ||
throw new ManifestNotFoundException( | ||
|
@@ -29,7 +34,7 @@ public static function getRecords(ViteHelperConfig $config): ManifestRecords | |
} | ||
|
||
// phpcs:ignore | ||
$json = @file_get_contents($manifestPath); | ||
$json = @file_get_contents($manifestPath); | ||
|
||
if ($json === false) { | ||
throw new ManifestNotFoundException('Could not parse manifest.json'); | ||
|
@@ -68,4 +73,9 @@ public static function getRecords(ViteHelperConfig $config): ManifestRecords | |
|
||
return new ManifestRecords($manifestArray, $manifestPath); | ||
} | ||
|
||
protected static function getPluginManifestPath(string $pluginName): string | ||
{ | ||
return Plugin::path($pluginName) . 'webroot' . DS . 'manifest.json'; | ||
} | ||
} |