mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
Check detected npm path is existing
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user