diff --git a/src/BiomeJsBinary.php b/src/BiomeJsBinary.php index bc2a369..2c7199a 100644 --- a/src/BiomeJsBinary.php +++ b/src/BiomeJsBinary.php @@ -161,8 +161,8 @@ public static function getBinaryName(): string default => throw new \Exception(sprintf('No matching machine found for Darwin platform (Machine: %s).', $machine)), }, str_contains($os, 'linux') => match ($machine) { - 'arm64', 'aarch64' => 'biome-linux-arm64', - 'x86_64' => 'biome-linux-x64', + 'arm64', 'aarch64' => self::isMusl() ? 'biome-linux-arm64-musl' : 'biome-linux-arm64', + 'x86_64' => self::isMusl() ? 'biome-linux-x64-musl' : 'biome-linux-x64', default => throw new \Exception(sprintf('No matching machine found for Linux platform (Machine: %s).', $machine)), }, str_contains($os, 'win') => match ($machine) { @@ -173,4 +173,26 @@ public static function getBinaryName(): string default => throw new \Exception(sprintf('Unknown platform or architecture (OS: %s, Machine: %s).', $os, $machine)), }; } + + /** + * Whether the current PHP environment is using musl libc. + * This is used to determine the correct Biome.js binary to download. + */ + private static function isMusl(): bool + { + static $isMusl = null; + + if (null !== $isMusl) { + return $isMusl; + } + + if (!\function_exists('phpinfo')) { + return $isMusl = false; + } + + ob_start(); + phpinfo(\INFO_GENERAL); + + return $isMusl = 1 === preg_match('/--build=.*?-linux-musl/', ob_get_clean() ?: ''); + } }