File tree 1 file changed +7
-5
lines changed
src/server/typingsInstaller 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace ts . server . typingsInstaller {
4
4
const fs : {
5
- appendFileSync ( file : string , content : string ) : void
5
+ appendFileSync ( file : string , content : string ) : void ;
6
+ existsSync ( path : string ) : boolean ;
6
7
} = require ( "fs" ) ;
7
8
8
9
const path : {
@@ -32,11 +33,12 @@ namespace ts.server.typingsInstaller {
32
33
/** Used if `--npmLocation` is not passed. */
33
34
function getDefaultNPMLocation ( processName : string ) {
34
35
if ( path . basename ( processName ) . indexOf ( "node" ) === 0 ) {
35
- return `"${ path . join ( path . dirname ( process . argv [ 0 ] ) , "npm" ) } "` ;
36
- }
37
- else {
38
- return "npm" ;
36
+ const npmPath = `"${ path . join ( path . dirname ( process . argv [ 0 ] ) , "npm" ) } "` ;
37
+ if ( fs . existsSync ( npmPath ) ) {
38
+ return npmPath ;
39
+ }
39
40
}
41
+ return "npm" ;
40
42
}
41
43
42
44
interface TypesRegistryFile {
You can’t perform that action at this time.
0 commit comments