mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 01:34:55 -06:00
Check detected npm path is existing
This commit is contained in:
parent
0f79b5b6f6
commit
1fda3a4165
@ -2,7 +2,8 @@
|
||||
|
||||
namespace ts.server.typingsInstaller {
|
||||
const fs: {
|
||||
appendFileSync(file: string, content: string): void
|
||||
appendFileSync(file: string, content: string): void;
|
||||
existsSync(path: string): boolean;
|
||||
} = require("fs");
|
||||
|
||||
const path: {
|
||||
@ -32,11 +33,12 @@ namespace ts.server.typingsInstaller {
|
||||
/** Used if `--npmLocation` is not passed. */
|
||||
function getDefaultNPMLocation(processName: string) {
|
||||
if (path.basename(processName).indexOf("node") === 0) {
|
||||
return `"${path.join(path.dirname(process.argv[0]), "npm")}"`;
|
||||
}
|
||||
else {
|
||||
return "npm";
|
||||
const npmPath = `"${path.join(path.dirname(process.argv[0]), "npm")}"`;
|
||||
if (fs.existsSync(npmPath)) {
|
||||
return npmPath;
|
||||
}
|
||||
}
|
||||
return "npm";
|
||||
}
|
||||
|
||||
interface TypesRegistryFile {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user