@@ -32,6 +32,7 @@ public function __construct(
3232 private ?string $ binaryVersion ,
3333 private ?SymfonyStyle $ output = null ,
3434 ?HttpClientInterface $ httpClient = null ,
35+ private string $ binaryPlatform = 'auto ' ,
3536 ) {
3637 $ this ->httpClient = $ httpClient ?? HttpClient::create ();
3738
@@ -95,7 +96,7 @@ private function getBinaryPath(): string
9596 return $ this ->binaryPath ;
9697 }
9798
98- $ this ->binaryPath = $ this ->binaryDownloadDir .'/ ' .$ this ->getVersion ().'/ ' .self ::getBinaryName ($ this ->getRawVersion ());
99+ $ this ->binaryPath = $ this ->binaryDownloadDir .'/ ' .$ this ->getVersion ().'/ ' .self ::getBinaryName ($ this ->getRawVersion (), $ this -> binaryPlatform );
99100
100101 if (!is_file ($ this ->binaryPath )) {
101102 $ this ->downloadExecutable ();
@@ -106,7 +107,7 @@ private function getBinaryPath(): string
106107
107108 private function downloadExecutable (): void
108109 {
109- $ binaryName = self ::getBinaryName ($ this ->getRawVersion ());
110+ $ binaryName = self ::getBinaryName ($ this ->getRawVersion (), $ this -> binaryPlatform );
110111 $ url = \sprintf ('https://github.com/tailwindlabs/tailwindcss/releases/download/%s/%s ' , $ this ->getVersion (), $ binaryName );
111112
112113 $ this ->output ?->note(\sprintf ('Downloading TailwindCSS binary from %s ' , $ url ));
@@ -146,8 +147,19 @@ private function downloadExecutable(): void
146147 /**
147148 * @internal
148149 */
149- public static function getBinaryName (string $ version ): string
150+ public static function getBinaryName (string $ version, string $ platform = ' auto ' ): string
150151 {
152+ $ system = self ::getBinarySystem ($ version , $ platform );
153+ $ isWindows = str_contains ($ system , 'windows ' );
154+
155+ return "tailwindcss- {$ system }" .(($ isWindows ) ? '.exe ' : '' );
156+ }
157+
158+ private static function getBinarySystem (string $ version , string $ platform ): string
159+ {
160+ if ('auto ' !== $ platform ) {
161+ return $ platform ;
162+ }
151163 $ os = strtolower (\PHP_OS );
152164 $ machine = strtolower (php_uname ('m ' ));
153165
@@ -183,11 +195,6 @@ public static function getBinaryName(string $version): string
183195
184196 // Detect MUSL only when version >= 4.0.0
185197 if ('linux ' === $ system && version_compare ($ version , '4.0.0 ' , '>= ' )) {
186- $ libs = [
187- 'x64 ' => 'x86_64 ' ,
188- 'arm64 ' => 'aarch64 ' ,
189- ];
190-
191198 $ isMusl = false ;
192199 if (is_executable ('/usr/bin/ldd ' ) || is_executable ('/bin/ldd ' )) {
193200 $ ldd = shell_exec ('ldd --version 2>&1 ' );
@@ -196,9 +203,9 @@ public static function getBinaryName(string $version): string
196203 }
197204 }
198205
199- return "tailwindcss- {$ system }- {$ arch }" .($ isMusl ? '-musl ' : '' );
206+ return "{$ system }- {$ arch }" .($ isMusl ? '-musl ' : '' );
200207 }
201208
202- return "tailwindcss- {$ system }- {$ arch }" .(( ' windows ' === $ system ) ? ' .exe ' : '' ) ;
209+ return "{$ system }- {$ arch }" ;
203210 }
204211}
0 commit comments