@@ -393,21 +393,14 @@ public static function getScreenSize($refresh = false)
393393 return $ size ;
394394 }
395395
396- if (self ::isOnWindows ()) {
397- $ output = [];
398- exec ('mode con ' , $ output );
399-
400- if (isset ($ output [1 ]) && strpos ($ output [1 ], 'CON ' ) !== false ) {
401- return ($ size = [
402- (int )preg_replace ('~\D~ ' , '' , $ output [3 ]),
403- (int )preg_replace ('~\D~ ' , '' , $ output [4 ])
404- ]);
405- }
406- } else {
396+ if (CliUtil::bashIsAvailable ()) {
407397 // try stty if available
408398 $ stty = [];
409- if (exec ('stty -a 2>&1 ' , $ stty ) && preg_match ('/rows\s+(\d+);\s*columns\s+(\d+);/mi ' , implode (' ' , $ stty ),
410- $ matches )) {
399+
400+ if (
401+ exec ('stty -a 2>&1 ' , $ stty ) &&
402+ preg_match ('/rows\s+(\d+);\s*columns\s+(\d+);/mi ' , implode (' ' , $ stty ), $ matches )
403+ ) {
411404 return ($ size = [$ matches [2 ], $ matches [1 ]]);
412405 }
413406
@@ -422,6 +415,18 @@ public static function getScreenSize($refresh = false)
422415 }
423416 }
424417
418+ if (self ::isOnWindows ()) {
419+ $ output = [];
420+ exec ('mode con ' , $ output );
421+
422+ if (isset ($ output [1 ]) && strpos ($ output [1 ], 'CON ' ) !== false ) {
423+ return ($ size = [
424+ (int )preg_replace ('~\D~ ' , '' , $ output [3 ]),
425+ (int )preg_replace ('~\D~ ' , '' , $ output [4 ])
426+ ]);
427+ }
428+ }
429+
425430 return ($ size = false );
426431 }
427432
0 commit comments