@@ -70,10 +70,10 @@ namespace ts.server.typingsInstaller {
7070 cwd : string ;
7171 encoding : "utf-8" ;
7272 }
73- type ExecSync = ( command : string , options : ExecSyncOptions ) => string ;
73+ type ExecFileSync = ( file : string , args : string [ ] , options : ExecSyncOptions ) => string ;
7474
7575 export class NodeTypingsInstaller extends TypingsInstaller {
76- private readonly nodeExecSync : ExecSync ;
76+ private readonly nodeExecFileSync : ExecFileSync ;
7777 private readonly npmPath : string ;
7878 readonly typesRegistry : Map < MapLike < string > > ;
7979
@@ -97,15 +97,15 @@ namespace ts.server.typingsInstaller {
9797 this . log . writeLine ( `Process id: ${ process . pid } ` ) ;
9898 this . log . writeLine ( `NPM location: ${ this . npmPath } (explicit '${ Arguments . NpmLocation } ' ${ npmLocation === undefined ? "not " : "" } provided)` ) ;
9999 }
100- ( { execSync : this . nodeExecSync } = require ( "child_process" ) ) ;
100+ ( { execFileSync : this . nodeExecFileSync } = require ( "child_process" ) ) ;
101101
102102 this . ensurePackageDirectoryExists ( globalTypingsCacheLocation ) ;
103103
104104 try {
105105 if ( this . log . isEnabled ( ) ) {
106106 this . log . writeLine ( `Updating ${ typesRegistryPackageName } npm package...` ) ;
107107 }
108- this . execSyncAndLog ( ` ${ this . npmPath } install --ignore-scripts ${ typesRegistryPackageName } @${ this . latestDistTag } `, { cwd : globalTypingsCacheLocation } ) ;
108+ this . execFileSyncAndLog ( this . npmPath , [ " install" , " --ignore-scripts" , ` ${ typesRegistryPackageName } @${ this . latestDistTag } `] , { cwd : globalTypingsCacheLocation } ) ;
109109 if ( this . log . isEnabled ( ) ) {
110110 this . log . writeLine ( `Updated ${ typesRegistryPackageName } npm package` ) ;
111111 }
@@ -189,20 +189,20 @@ namespace ts.server.typingsInstaller {
189189 this . log . writeLine ( `#${ requestId } with arguments'${ JSON . stringify ( packageNames ) } '.` ) ;
190190 }
191191 const start = Date . now ( ) ;
192- const hasError = installNpmPackages ( this . npmPath , version , packageNames , command => this . execSyncAndLog ( command , { cwd } ) ) ;
192+ const hasError = installNpmPackages ( this . npmPath , version , packageNames , ( file , args ) => this . execFileSyncAndLog ( file , args , { cwd } ) ) ;
193193 if ( this . log . isEnabled ( ) ) {
194194 this . log . writeLine ( `npm install #${ requestId } took: ${ Date . now ( ) - start } ms` ) ;
195195 }
196196 onRequestCompleted ( ! hasError ) ;
197197 }
198198
199199 /** Returns 'true' in case of error. */
200- private execSyncAndLog ( command : string , options : Pick < ExecSyncOptions , "cwd" > ) : boolean {
200+ private execFileSyncAndLog ( file : string , args : string [ ] , options : Pick < ExecSyncOptions , "cwd" > ) : boolean {
201201 if ( this . log . isEnabled ( ) ) {
202- this . log . writeLine ( `Exec: ${ command } ` ) ;
202+ this . log . writeLine ( `Exec: ${ file } ${ args . join ( " " ) } ` ) ;
203203 }
204204 try {
205- const stdout = this . nodeExecSync ( command , { ...options , encoding : "utf-8" } ) ;
205+ const stdout = this . nodeExecFileSync ( file , args , { ...options , encoding : "utf-8" } ) ;
206206 if ( this . log . isEnabled ( ) ) {
207207 this . log . writeLine ( ` Succeeded. stdout:${ indent ( sys . newLine , stdout ) } ` ) ;
208208 }
0 commit comments