File tree Expand file tree Collapse file tree 4 files changed +18
-11
lines changed Expand file tree Collapse file tree 4 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 1- 7C57EC370DB9656684D0C8325B8D889DDE1D90C286CBD38F9DFA997A96AF1212EA6518E6DE88DA8476F5A7A34FA2D5EBC5BC0914AA7EC73B36FBE53C4ABB3357
1+ 679D81B7198B1960B0FD84EECB611AE03AA656CCB75FBEAC6DA3E4C2E8D5A515C2C6A01D213E8BC5D3227D677BE7CB8D442F576D80A09FA71956E26539550DB6
Original file line number Diff line number Diff line change 44
55use React \Stream \WritableResourceStream ;
66
7+ use function fflush ;
78use function Nightwatch \fwrite_all ;
89
910class OutputWriter
1011{
11- private WritableResourceStream $ loopStream ;
12-
1312 /**
14- * @param resource $stream
13+ * @param resource $syncStream
1514 */
1615 public function __construct (
1716 private Loop $ loop ,
18- private $ stream ,
17+ private $ syncStream ,
18+ private ?WritableResourceStream $ asyncStream ,
1919 ) {
20- $ this -> loopStream = new WritableResourceStream ( $ stream );
20+ //
2121 }
2222
2323 public function write (string $ message ): void
2424 {
25- if ($ this ->loop ->running ()) {
26- $ this ->loopStream ->write ($ message );
25+ if ($ this ->loop ->running () && $ this -> asyncStream !== null ) {
26+ $ this ->asyncStream ->write ($ message );
2727 } else {
28- fwrite_all ($ this ->stream , $ message );
28+ fwrite_all ($ this ->syncStream , $ message );
29+ fflush ($ this ->syncStream );
2930 }
3031 }
3132}
Original file line number Diff line number Diff line change 1212use React \EventLoop \StreamSelectLoop ;
1313use React \Socket \ServerInterface ;
1414use React \Socket \TcpServer ;
15+ use React \Stream \WritableResourceStream ;
1516
1617use function date ;
1718use function file_get_contents ;
8283 * Logging helpers...
8384 */
8485
85- $ stdOut = new OutputWriter ($ loop , STDOUT );
86- $ stdErr = new OutputWriter ($ loop , STDERR );
86+ [$ asyncStdOut , $ asyncStdError ] = match (PHP_OS_FAMILY ) {
87+ 'Windows ' => [null , null ],
88+ default => [new WritableResourceStream (STDOUT ), new WritableResourceStream (STDERR )],
89+ };
90+
91+ $ stdOut = new OutputWriter ($ loop , syncStream: STDOUT , asyncStream: $ asyncStdOut );
92+ $ stdErr = new OutputWriter ($ loop , syncStream: STDERR , asyncStream: $ asyncStdError );
8793
8894$ debug = static function (string $ message ) use ($ verbose , $ stdOut ): void {
8995 if ($ verbose ) {
You can’t perform that action at this time.
0 commit comments