File tree Expand file tree Collapse file tree
apps/demos/utils/ts-to-js-converter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,15 +79,23 @@ const pipeSource = async (
7979} ;
8080
8181const execTsc = async ( directory : string , args : string [ ] ) : Promise < string > => new Promise ( ( resolve , reject ) => {
82- const proc = cps . spawn ( 'tsc' , args ) ;
82+ const proc = cps . spawn ( 'tsc' , args , { cwd : directory } ) ;
8383 let stdout = '' ;
8484 let stderr = '' ;
8585 proc . stdout . on ( 'data' , ( data : Buffer ) => { stdout += data . toString ( ) ; } ) ;
8686 proc . stderr . on ( 'data' , ( data : Buffer ) => { stderr += data . toString ( ) ; } ) ;
87- proc . on ( 'close' , ( code : number ) => {
87+ proc . on ( 'error' , ( err : Error ) => {
88+ // eslint-disable-next-line prefer-promise-reject-errors
89+ reject ( `tsc failed to spawn: ${ err . message } ` ) ;
90+ } ) ;
91+ proc . on ( 'close' , ( code : number | null , signal : NodeJS . Signals | null ) => {
92+ if ( signal !== null ) {
93+ // eslint-disable-next-line prefer-promise-reject-errors
94+ return reject ( `tsc killed by signal ${ signal } \n${ stderr } \n${ stdout } ` ) ;
95+ }
8896 if ( code !== 0 ) {
8997 // eslint-disable-next-line prefer-promise-reject-errors
90- return reject ( `Exit code ${ code } \n${ stderr } \n${ stdout } ` ) ;
98+ return reject ( `tsc exited with code ${ code } \n${ stderr } \n${ stdout } ` ) ;
9199 }
92100 return resolve ( stdout ) ;
93101 } ) ;
You can’t perform that action at this time.
0 commit comments