@@ -13,6 +13,7 @@ namespace ts.server {
1313 globalTypingsCacheLocation : string ;
1414 logger : Logger ;
1515 typingSafeListLocation : string ;
16+ npmLocation : string | undefined ;
1617 telemetryEnabled : boolean ;
1718 globalPlugins : string [ ] ;
1819 pluginProbeLocations : string [ ] ;
@@ -234,6 +235,7 @@ namespace ts.server {
234235 eventPort : number ,
235236 readonly globalTypingsCacheLocation : string ,
236237 readonly typingSafeListLocation : string ,
238+ private readonly npmLocation : string | undefined ,
237239 private newLine : string ) {
238240 this . throttledOperations = new ThrottledOperations ( host ) ;
239241 if ( eventPort ) {
@@ -278,19 +280,21 @@ namespace ts.server {
278280 if ( this . typingSafeListLocation ) {
279281 args . push ( Arguments . TypingSafeListLocation , this . typingSafeListLocation ) ;
280282 }
283+ if ( this . npmLocation ) {
284+ args . push ( Arguments . NpmLocation , this . npmLocation ) ;
285+ }
286+
281287 const execArgv : string [ ] = [ ] ;
282- {
283- for ( const arg of process . execArgv ) {
284- const match = / ^ - - ( d e b u g | i n s p e c t ) ( = ( \d + ) ) ? $ / . exec ( arg ) ;
285- if ( match ) {
286- // if port is specified - use port + 1
287- // otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1
288- const currentPort = match [ 3 ] !== undefined
289- ? + match [ 3 ]
290- : match [ 1 ] === "debug" ? 5858 : 9229 ;
291- execArgv . push ( `--${ match [ 1 ] } =${ currentPort + 1 } ` ) ;
292- break ;
293- }
288+ for ( const arg of process . execArgv ) {
289+ const match = / ^ - - ( d e b u g | i n s p e c t ) ( = ( \d + ) ) ? $ / . exec ( arg ) ;
290+ if ( match ) {
291+ // if port is specified - use port + 1
292+ // otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1
293+ const currentPort = match [ 3 ] !== undefined
294+ ? + match [ 3 ]
295+ : match [ 1 ] === "debug" ? 5858 : 9229 ;
296+ execArgv . push ( `--${ match [ 1 ] } =${ currentPort + 1 } ` ) ;
297+ break ;
294298 }
295299 }
296300
@@ -389,10 +393,10 @@ namespace ts.server {
389393
390394 class IOSession extends Session {
391395 constructor ( options : IOSessionOptions ) {
392- const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, canUseEvents } = options ;
396+ const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation , canUseEvents } = options ;
393397 const typingsInstaller = disableAutomaticTypingAcquisition
394398 ? undefined
395- : new NodeTypingsInstaller ( telemetryEnabled , logger , host , installerEventPort , globalTypingsCacheLocation , typingSafeListLocation , host . newLine ) ;
399+ : new NodeTypingsInstaller ( telemetryEnabled , logger , host , installerEventPort , globalTypingsCacheLocation , typingSafeListLocation , npmLocation , host . newLine ) ;
396400
397401 super ( {
398402 host,
@@ -742,7 +746,8 @@ namespace ts.server {
742746 validateLocaleAndSetLanguage ( localeStr , sys ) ;
743747 }
744748
745- const typingSafeListLocation = findArgument ( "--typingSafeListLocation" ) ;
749+ const typingSafeListLocation = findArgument ( Arguments . TypingSafeListLocation ) ;
750+ const npmLocation = findArgument ( Arguments . NpmLocation ) ;
746751
747752 const globalPlugins = ( findArgument ( "--globalPlugins" ) || "" ) . split ( "," ) ;
748753 const pluginProbeLocations = ( findArgument ( "--pluginProbeLocations" ) || "" ) . split ( "," ) ;
@@ -761,6 +766,7 @@ namespace ts.server {
761766 disableAutomaticTypingAcquisition,
762767 globalTypingsCacheLocation : getGlobalTypingsCacheLocation ( ) ,
763768 typingSafeListLocation,
769+ npmLocation,
764770 telemetryEnabled,
765771 logger,
766772 globalPlugins,
0 commit comments