@@ -64,37 +64,32 @@ export function spawnSafe(cmd: string, options?: SpawnOptions): Promise<SpawnRes
6464 output . push ( data . toString ( ) ) ;
6565 } )
6666
67- const resizeListener = ( ) => {
68- const { columns, rows } = process . stdout ;
69- mPty . resize ( columns , rows ) ;
70- }
7167
7268 const stdinListener = ( data : any ) => {
7369 // console.log('stdinListener', data);
7470 mPty . write ( data . toString ( ) ) ;
7571 }
7672
77- // Listen to resize events for the terminal window;
78- process . stdout . on ( 'resize' , resizeListener ) ;
7973 if ( options ?. stdin ) {
8074 process . stdin . on ( 'data' , stdinListener )
8175 }
8276
8377 mPty . onExit ( ( result ) => {
84- process . stdout . off ( 'resize' , resizeListener ) ;
8578 if ( options ?. stdin ) {
8679 process . stdin . off ( 'data' , stdinListener ) ;
8780 }
8881
82+ const raw = stripAnsi ( output . join ( '' ) ) . replace ( / \r \n / g, '\n' ) . replace ( / \r / g, '\n' ) . trim ( ) ;
83+
8984 if ( options ?. throws && result . exitCode !== 0 ) {
90- reject ( new Error ( stripAnsi ( output . join ( '\n' ) . trim ( ) ) ) ) ;
85+ reject ( new Error ( raw ) ) ;
9186 return ;
9287 }
9388
9489 resolve ( {
9590 status : result . exitCode === 0 ? SpawnStatus . SUCCESS : SpawnStatus . ERROR ,
9691 exitCode : result . exitCode ,
97- data : stripAnsi ( output . join ( '\n' ) . trim ( ) ) ,
92+ data : raw ,
9893 } )
9994 } )
10095 } )
0 commit comments