@@ -13,6 +13,7 @@ namespace ts.server {
13
13
globalTypingsCacheLocation : string ;
14
14
logger : Logger ;
15
15
typingSafeListLocation : string ;
16
+ npmLocation : string | undefined ;
16
17
telemetryEnabled : boolean ;
17
18
globalPlugins : string [ ] ;
18
19
pluginProbeLocations : string [ ] ;
@@ -234,6 +235,7 @@ namespace ts.server {
234
235
eventPort : number ,
235
236
readonly globalTypingsCacheLocation : string ,
236
237
readonly typingSafeListLocation : string ,
238
+ private readonly npmLocation : string | undefined ,
237
239
private newLine : string ) {
238
240
this . throttledOperations = new ThrottledOperations ( host ) ;
239
241
if ( eventPort ) {
@@ -278,19 +280,21 @@ namespace ts.server {
278
280
if ( this . typingSafeListLocation ) {
279
281
args . push ( Arguments . TypingSafeListLocation , this . typingSafeListLocation ) ;
280
282
}
283
+ if ( this . npmLocation ) {
284
+ args . push ( Arguments . NpmLocation , this . npmLocation ) ;
285
+ }
286
+
281
287
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 ;
294
298
}
295
299
}
296
300
@@ -389,10 +393,10 @@ namespace ts.server {
389
393
390
394
class IOSession extends Session {
391
395
constructor ( options : IOSessionOptions ) {
392
- const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, canUseEvents } = options ;
396
+ const { host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, npmLocation , canUseEvents } = options ;
393
397
const typingsInstaller = disableAutomaticTypingAcquisition
394
398
? undefined
395
- : new NodeTypingsInstaller ( telemetryEnabled , logger , host , installerEventPort , globalTypingsCacheLocation , typingSafeListLocation , host . newLine ) ;
399
+ : new NodeTypingsInstaller ( telemetryEnabled , logger , host , installerEventPort , globalTypingsCacheLocation , typingSafeListLocation , npmLocation , host . newLine ) ;
396
400
397
401
super ( {
398
402
host,
@@ -742,7 +746,8 @@ namespace ts.server {
742
746
validateLocaleAndSetLanguage ( localeStr , sys ) ;
743
747
}
744
748
745
- const typingSafeListLocation = findArgument ( "--typingSafeListLocation" ) ;
749
+ const typingSafeListLocation = findArgument ( Arguments . TypingSafeListLocation ) ;
750
+ const npmLocation = findArgument ( Arguments . NpmLocation ) ;
746
751
747
752
const globalPlugins = ( findArgument ( "--globalPlugins" ) || "" ) . split ( "," ) ;
748
753
const pluginProbeLocations = ( findArgument ( "--pluginProbeLocations" ) || "" ) . split ( "," ) ;
@@ -761,6 +766,7 @@ namespace ts.server {
761
766
disableAutomaticTypingAcquisition,
762
767
globalTypingsCacheLocation : getGlobalTypingsCacheLocation ( ) ,
763
768
typingSafeListLocation,
769
+ npmLocation,
764
770
telemetryEnabled,
765
771
logger,
766
772
globalPlugins,
0 commit comments