catch exception when license path key is not set, fix libxslt license

This commit is contained in:
DubbleClick 2023-10-16 22:58:49 +02:00 committed by Jerry Ma
parent ce60a9c804
commit 2e3544f296
2 changed files with 5 additions and 2 deletions

View File

@ -270,7 +270,7 @@
"regex": "/href=\"(?<file>libxslt-(?<version>[^\"]+)\\.tar\\.xz)\"/", "regex": "/href=\"(?<file>libxslt-(?<version>[^\"]+)\\.tar\\.xz)\"/",
"license": { "license": {
"type": "file", "type": "file",
"text": "COPYING" "path": "COPYING"
} }
}, },
"libyaml": { "libyaml": {

View File

@ -102,8 +102,11 @@ class LicenseDumper
/** /**
* @throws RuntimeException * @throws RuntimeException
*/ */
private function loadSourceFile(string $source_name, string $in_path, ?string $custom_base_path = null): string private function loadSourceFile(string $source_name, ?string $in_path, ?string $custom_base_path = null): string
{ {
if (is_null($in_path)) {
throw new RuntimeException('source [' . $source_name . '] license file is not set, please check config/source.json');
}
if (!file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path)) { if (!file_exists(SOURCE_PATH . '/' . ($custom_base_path ?? $source_name) . '/' . $in_path)) {
throw new RuntimeException('source [' . $source_name . '] license file [' . $in_path . '] not exist'); throw new RuntimeException('source [' . $source_name . '] license file [' . $in_path . '] not exist');
} }