Special case TS dev version detection

Allow pointing to a TS local build without setting `tsdk_version`

Fixes #33977
This commit is contained in:
Matt Bierner
2017-09-25 15:31:43 -07:00
parent 67df88dbce
commit 754738ca4b

View File

@@ -58,17 +58,24 @@ export class TypeScriptVersion {
return undefined;
}
let p = serverPath.split(path.sep);
const p = serverPath.split(path.sep);
if (p.length <= 2) {
return undefined;
}
let p2 = p.slice(0, -2);
let modulePath = p2.join(path.sep);
const p2 = p.slice(0, -2);
const modulePath = p2.join(path.sep);
let fileName = path.join(modulePath, 'package.json');
if (!fs.existsSync(fileName)) {
// Special case for ts dev versions
if (path.basename(modulePath) === 'built') {
fileName = path.join(modulePath, '..', 'package.json');
}
}
if (!fs.existsSync(fileName)) {
return undefined;
}
let contents = fs.readFileSync(fileName).toString();
const contents = fs.readFileSync(fileName).toString();
let desc: any = null;
try {
desc = JSON.parse(contents);