@@ -52,6 +52,9 @@ namespace ts.server.typingsInstaller {
5252
5353 constructor ( log ?: Log ) {
5454 super ( getGlobalCacheLocation ( ) , toPath ( "typingSafeList.json" , __dirname , createGetCanonicalFileName ( sys . useCaseSensitiveFileNames ) ) , log ) ;
55+ if ( this . log . isEnabled ( ) ) {
56+ this . log . writeLine ( `Process id: ${ process . pid } ` ) ;
57+ }
5558 const { exec, execSync } = require ( "child_process" ) ;
5659 this . execSync = execSync ;
5760 this . exec = exec ;
@@ -84,20 +87,34 @@ namespace ts.server.typingsInstaller {
8487
8588 protected isPackageInstalled ( packageName : string ) {
8689 try {
87- this . execSync ( `npm list --global --depth=1 ${ packageName } ` , { stdio : "ignore" } ) ;
90+ const output = this . execSync ( `npm list --global --depth=1 ${ packageName } ` , { stdio : "pipe" } ) . toString ( ) ;
91+ if ( this . log . isEnabled ( ) ) {
92+ this . log . writeLine ( `IsPackageInstalled::stdout '${ output } '` ) ;
93+ }
8894 return true ;
8995 }
9096 catch ( e ) {
97+ if ( this . log . isEnabled ( ) ) {
98+ this . log . writeLine ( `IsPackageInstalled::err::stdout '${ e . stdout && e . stdout . toString ( ) } '` ) ;
99+ this . log . writeLine ( `IsPackageInstalled::err::stderr '${ e . stdout && e . stderr . toString ( ) } '` ) ;
100+ }
91101 return false ;
92102 }
93103 }
94104
95105 protected installPackage ( packageName : string ) {
96106 try {
97- this . execSync ( `npm install --global ${ packageName } ` , { stdio : "ignore" } ) ;
107+ const output = this . execSync ( `npm install --global ${ packageName } ` , { stdio : "pipe" } ) . toString ( ) ;
108+ if ( this . log . isEnabled ( ) ) {
109+ this . log . writeLine ( `installPackage::stdout '${ output } '` ) ;
110+ }
98111 return true ;
99112 }
100113 catch ( e ) {
114+ if ( this . log . isEnabled ( ) ) {
115+ this . log . writeLine ( `installPackage::err::stdout '${ e . stdout && e . stdout . toString ( ) } '` ) ;
116+ this . log . writeLine ( `installPackage::err::stderr '${ e . stdout && e . stderr . toString ( ) } '` ) ;
117+ }
101118 return false ;
102119 }
103120 }
@@ -107,6 +124,9 @@ namespace ts.server.typingsInstaller {
107124 this . log . writeLine ( `Sending response: ${ JSON . stringify ( response ) } ` )
108125 }
109126 process . send ( response ) ;
127+ if ( this . log . isEnabled ( ) ) {
128+ this . log . writeLine ( `Response has been sent.` )
129+ }
110130 }
111131
112132 protected runTsd ( cachePath : string , typingsToInstall : string [ ] , postInstallAction : ( installedTypings : string [ ] ) => void ) : void {
@@ -139,11 +159,15 @@ namespace ts.server.typingsInstaller {
139159 }
140160
141161 const log = new FileLog ( process . env . TI_LOG_FILE ) ;
142- process . on ( "uncaughtException" , ( e : Error ) => {
143- if ( log . isEnabled ( ) ) {
162+ if ( log . isEnabled ( ) ) {
163+ process . on ( "uncaughtException" , ( e : Error ) => {
144164 log . writeLine ( `Unhandled exception: ${ e } at ${ e . stack } ` ) ;
145- }
146- } )
165+ } ) ;
166+ process . on ( "disconnect" , ( ) => {
167+ log . writeLine ( `Parent process has exited, shutting down...` ) ;
168+ process . exit ( 0 ) ;
169+ } ) ;
170+ }
147171 const installer = new NodeTypingsInstaller ( log ) ;
148172 installer . init ( ) ;
149173}
0 commit comments