@@ -24,9 +24,9 @@ use tokio::{
2424 io:: { AsyncBufReadExt , BufReader } ,
2525 process:: Command as AsyncCommand ,
2626 runtime:: Runtime ,
27- stream:: StreamExt ,
2827 time,
2928} ;
29+ use tokio_stream:: { wrappers:: LinesStream , StreamExt } ;
3030
3131lazy_static:: lazy_static! {
3232 // TODO: Migrate to asynchronous code and remove runtime
@@ -480,7 +480,6 @@ impl<'w, 'pl> Command<'w, 'pl> {
480480 }
481481
482482 let out = RUNTIME
483- . handle ( )
484483 . block_on ( log_command (
485484 cmd,
486485 self . process_lines ,
@@ -574,13 +573,11 @@ async fn log_command(
574573 } ;
575574
576575 let mut child = cmd. stdout ( Stdio :: piped ( ) ) . stderr ( Stdio :: piped ( ) ) . spawn ( ) ?;
577- let child_id = child. id ( ) ;
576+ let child_id = child. id ( ) . unwrap ( ) ;
578577
579- let stdout = BufReader :: new ( child. stdout . take ( ) . unwrap ( ) )
580- . lines ( )
578+ let stdout = LinesStream :: new ( BufReader :: new ( child. stdout . take ( ) . unwrap ( ) ) . lines ( ) )
581579 . map ( |line| ( OutputKind :: Stdout , line) ) ;
582- let stderr = BufReader :: new ( child. stderr . take ( ) . unwrap ( ) )
583- . lines ( )
580+ let stderr = LinesStream :: new ( BufReader :: new ( child. stderr . take ( ) . unwrap ( ) ) . lines ( ) )
584581 . map ( |line| ( OutputKind :: Stderr , line) ) ;
585582
586583 let start = Instant :: now ( ) ;
@@ -642,7 +639,7 @@ async fn log_command(
642639 } ,
643640 ) ;
644641
645- let child = time:: timeout ( timeout, child) . map ( move |result| {
642+ let child = time:: timeout ( timeout, child. wait ( ) ) . map ( move |result| {
646643 match result {
647644 // If the timeout elapses, kill the process
648645 Err ( _timeout) => Err ( match native:: kill_process ( child_id) {
0 commit comments