@@ -114,23 +114,29 @@ namespace ts.server.typingsInstaller {
114114 protected runInstall ( cachePath : string , typingsToInstall : string [ ] , postInstallAction : ( installedTypings : string [ ] ) => void ) : void {
115115 const id = this . installRunCount ;
116116 this . installRunCount ++ ;
117- const command = `npm install ${ typingsToInstall . map ( t => "@types/" + t ) . join ( " " ) } --save-dev` ;
118- if ( this . log . isEnabled ( ) ) {
119- this . log . writeLine ( `Running npm install @types ${ id } , command '${ command } '. cache path '${ cachePath } '` ) ;
120- }
121- this . exec ( command , { cwd : cachePath } , ( err , stdout , stderr ) => {
117+ let installCount = 0 ;
118+ const installedTypings : string [ ] = [ ] ;
119+ const expr = / ^ .* ( @ t y p e s \/ \w + ) \S * \s * $ / gm;
120+ let match : RegExpExecArray ;
121+ for ( const typing of typingsToInstall ) {
122+ const command = `npm install @types/${ typing } --save-dev` ;
122123 if ( this . log . isEnabled ( ) ) {
123- this . log . writeLine ( `npm install @types ${ id } stdout: ${ stdout } ` ) ;
124- this . log . writeLine ( `npm install @types ${ id } stderr: ${ stderr } ` ) ;
125- }
126- const installedTypings : string [ ] = [ ] ;
127- const expr = / ^ .* ( n o d e _ m o d u l e s ) \\ ( @ t y p e s ) \\ ( \S + ) \s * $ / gm;
128- let match : RegExpExecArray ;
129- while ( match = expr . exec ( stdout ) ) {
130- installedTypings . push ( `${ match [ 1 ] } /${ match [ 2 ] } /${ match [ 3 ] } ` ) ;
124+ this . log . writeLine ( `Running npm install @types ${ id } , command '${ command } '. cache path '${ cachePath } '` ) ;
131125 }
132- postInstallAction ( installedTypings ) ;
133- } ) ;
126+ this . exec ( command , { cwd : cachePath } , ( err , stdout , stderr ) => {
127+ installCount ++ ;
128+ if ( this . log . isEnabled ( ) ) {
129+ this . log . writeLine ( `npm install @types ${ id } stdout: ${ stdout } ` ) ;
130+ this . log . writeLine ( `npm install @types ${ id } stderr: ${ stderr } ` ) ;
131+ }
132+ while ( match = expr . exec ( stdout ) ) {
133+ installedTypings . push ( `node_modules/${ match [ 1 ] } ` ) ;
134+ }
135+ if ( installCount >= typingsToInstall . length ) {
136+ postInstallAction ( installedTypings ) ;
137+ }
138+ } ) ;
139+ }
134140 }
135141 }
136142
0 commit comments