@@ -571,9 +571,11 @@ class Connection {
571571 } ) ;
572572 }
573573
574- // Executes a command, fulfilling with the command's stdout
575- // or rejecting if output is received on stderr.
576- private exec_ = ( command :string ) : Promise < string > => {
574+ // Executes a command, fulfilling with the first line of the command's
575+ // output on stdout or rejecting if any output is received on stderr.
576+ // TODO: There is a close event with a return code which
577+ // is probably a better indication of success.
578+ private exec_ = ( command : string ) : Promise < string > => {
577579 log . debug ( '%1: execute command: %2' , this . name_ , command ) ;
578580 if ( this . state_ !== ConnectionState . ESTABLISHED ) {
579581 return Promise . reject ( new Error ( 'can only execute commands in ESTABLISHED state' ) ) ;
@@ -587,13 +589,16 @@ class Connection {
587589 return ;
588590 }
589591
590- // TODO: There is a close event with a return code which
591- // is probably a better indication of success.
592+ var stdout = new queue . Queue < ArrayBuffer , void > ( ) ;
593+ new linefeeder . LineFeeder ( stdout ) . setSyncHandler ( ( line : string ) => {
594+ F ( line ) ;
595+ } ) ;
596+
592597 stream . on ( 'data' , ( data : Buffer ) => {
593- F ( data . toString ( ) ) ;
598+ stdout . handle ( arraybuffers . bufferToArrayBuffer ( data ) ) ;
594599 } ) . stderr . on ( 'data' , ( data : Buffer ) => {
595600 R ( {
596- message : 'command output to STDERR: ' + data . toString ( )
601+ message : 'output received on STDERR: ' + data . toString ( )
597602 } ) ;
598603 } ) . on ( 'end' , ( ) => {
599604 log . debug ( '%1: exec stream end' , this . name_ ) ;
0 commit comments