@@ -82,16 +82,32 @@ public function download(string $version): void
8282 $ this ->filesystem ->appendToFile ($ downloadFilename , $ chunk ->getContent (), true );
8383 }
8484
85- // TODO windows
85+ if (str_ends_with ($ downloadFilename , '.zip ' )) {
86+ $ download = function () use ($ downloadFilename , $ tempDir ) {
87+ $ archive = new \ZipArchive ();
88+ $ archive ->open ($ downloadFilename );
89+ $ archive ->extractTo ($ tempDir , 'minify ' );
90+ $ archive ->close ();
91+ };
92+ } else {
93+ $ download = function () use ($ downloadFilename , $ tempDir ) {
94+ $ archive = new \PharData ($ downloadFilename );
95+ $ archive ->extractTo ($ tempDir , ['minify ' ], true );
96+ };
97+ }
8698
87- $ archive = new \PharData ($ downloadFilename );
88- if (!isset ($ archive ['minify ' ])) {
89- throw new LogicException ('The minify binary is missing from the archive. ' );
99+ try {
100+ $ download ();
101+ } catch (\Throwable $ e ) {
102+ throw new InstallException (sprintf ('Error extracting the binary from archive "%s". ' , $ downloadFilename ), 0 , $ e ->getPrevious ());
90103 }
91- $ archive ->extractTo ($ tempDir , ['minify ' ], true );
92104
93105 $ this ->filesystem ->mkdir (dirname ($ this ->getInstallBinaryPath ()));
94- $ this ->filesystem ->copy (Path::join ($ tempDir , 'minify ' ), $ this ->getInstallBinaryPath ());
106+ if (str_ends_with ($ downloadFilename , '.zip ' )) {
107+ $ this ->filesystem ->copy (Path::join ($ tempDir , 'minify.exe ' ), $ this ->getInstallBinaryPath ());
108+ } else {
109+ $ this ->filesystem ->copy (Path::join ($ tempDir , 'minify ' ), $ this ->getInstallBinaryPath ());
110+ }
95111 $ this ->filesystem ->remove ($ tempDir );
96112 }
97113
0 commit comments