@@ -25,11 +25,11 @@ export function callTsProxy(tsCode, silent=false) {
2525 const child = spawn ( "tsx" , [ path . join ( currentFileFolder , "proxy.ts" ) ] , {
2626 env : process . env ,
2727 } ) ;
28- let stdout = "" ;
2928 let stderr = "" ;
29+ let stdoutLogs = [ ] ;
3030
3131 child . stdout . on ( "data" , ( data ) => {
32- stdout += data ;
32+ stdoutLogs . push ( data . toString ( ) ) ;
3333 } ) ;
3434
3535 child . stderr . on ( "data" , ( data ) => {
@@ -39,7 +39,12 @@ export function callTsProxy(tsCode, silent=false) {
3939 child . on ( "close" , ( code ) => {
4040 if ( code === 0 ) {
4141 try {
42- const preparedStdout = stdout . slice ( stdout . indexOf ( "{" ) , stdout . lastIndexOf ( "}" ) + 1 ) ;
42+ const tsProxyResult = stdoutLogs . find ( log => log . includes ( '>>>>>>>' ) ) ;
43+ const preparedStdout = tsProxyResult . slice ( tsProxyResult . indexOf ( '>>>>>>>' ) + 46 , tsProxyResult . lastIndexOf ( '<<<<<<<' ) ) ;
44+ const preparedStdoutLogs = stdoutLogs . filter ( log => ! log . includes ( '>>>>>>>' ) ) ;
45+ for ( const log of preparedStdoutLogs ) {
46+ console . log ( log ) ;
47+ }
4348 const parsed = JSON . parse ( preparedStdout ) ;
4449 if ( ! silent ) {
4550 parsed . capturedLogs . forEach ( ( log ) => {
@@ -52,10 +57,10 @@ export function callTsProxy(tsCode, silent=false) {
5257 }
5358 resolve ( parsed . result ) ;
5459 } catch ( e ) {
55- reject ( new Error ( "Invalid JSON from tsproxy: " + stdout ) ) ;
60+ reject ( new Error ( "Invalid JSON from tsproxy: " + preparedStdout ) ) ;
5661 }
5762 } else {
58- console . error ( `tsproxy exited with non-0, this should never happen, stdout: ${ stdout } , stderr: ${ stderr } ` ) ;
63+ console . error ( `tsproxy exited with non-0, this should never happen, stdout: ${ preparedStdout } , stderr: ${ stderr } ` ) ;
5964 reject ( new Error ( stderr ) ) ;
6065 }
6166 } ) ;
0 commit comments