allow compilation with empty target

This commit is contained in:
DubbleClick 2025-07-01 23:31:54 +07:00
parent d8ee308a5f
commit 719bde87b7

View File

@ -86,16 +86,13 @@ class SPCTarget
*/ */
public static function getTargetOS(): string public static function getTargetOS(): string
{ {
$target = getenv('SPC_TARGET'); $target = (string) getenv('SPC_TARGET');
if ($target === false) {
return PHP_OS_FAMILY;
}
return match (true) { return match (true) {
str_contains($target, '-linux') => 'Linux', str_contains($target, '-linux') => 'Linux',
str_contains($target, '-macos') => 'Darwin', str_contains($target, '-macos') => 'Darwin',
str_contains($target, '-windows') => 'Windows', str_contains($target, '-windows') => 'Windows',
str_contains($target, '-native') => PHP_OS_FAMILY, str_contains($target, '-native') => PHP_OS_FAMILY,
default => throw new WrongUsageException('Cannot parse target.'), default => PHP_OS_FAMILY,
}; };
} }
} }