mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 01:45:36 +08:00
Fix config yaml support
This commit is contained in:
@@ -6,6 +6,7 @@ namespace StaticPHP\Config;
|
|||||||
|
|
||||||
use StaticPHP\Exception\WrongUsageException;
|
use StaticPHP\Exception\WrongUsageException;
|
||||||
use StaticPHP\Registry\Registry;
|
use StaticPHP\Registry\Registry;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class ArtifactConfig
|
class ArtifactConfig
|
||||||
{
|
{
|
||||||
@@ -40,7 +41,11 @@ class ArtifactConfig
|
|||||||
if ($content === false) {
|
if ($content === false) {
|
||||||
throw new WrongUsageException("Failed to read artifact config file: {$file}");
|
throw new WrongUsageException("Failed to read artifact config file: {$file}");
|
||||||
}
|
}
|
||||||
$data = json_decode($content, true);
|
$data = match (pathinfo($file, PATHINFO_EXTENSION)) {
|
||||||
|
'json' => json_decode($content, true),
|
||||||
|
'yml', 'yaml' => Yaml::parse($content),
|
||||||
|
default => throw new WrongUsageException("Unsupported artifact config file format: {$file}"),
|
||||||
|
};
|
||||||
if (!is_array($data)) {
|
if (!is_array($data)) {
|
||||||
throw new WrongUsageException("Invalid JSON format in artifact config file: {$file}");
|
throw new WrongUsageException("Invalid JSON format in artifact config file: {$file}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user