Restore automatically putting TS Server in debug more if TSS_DEBUG is set

Fixes https://github.com/Microsoft/TypeScript/issues/21454
This commit is contained in:
Matt Bierner
2018-01-29 10:46:37 -08:00
parent 390a5295b0
commit 41afff235b

View File

@@ -354,8 +354,9 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return this.servicePromise = new Promise<ForkedTsServerProcess>(async (resolve, reject) => {
try {
const tsServerForkArgs = await this.getTsServerArgs(currentVersion);
const debugPort = this.getDebugPort();
const tsServerForkOptions: electron.IForkOptions = {
execArgv: [] // [`--debug-brk=5859`]
execArgv: debugPort ? [`--inspect=${debugPort}`] : [] // [`--debug-brk=5859`]
};
electron.fork(currentVersion.tsServerPath, tsServerForkArgs, tsServerForkOptions, this.logger, (err: any, childProcess: cp.ChildProcess | null) => {
if (err || !childProcess) {
@@ -942,6 +943,18 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
return args;
}
private getDebugPort(): number | undefined {
const value = process.env['TSS_DEBUG'];
if (value) {
const port = parseInt(value);
if (!isNaN(port)) {
return port;
}
}
return undefined;
}
private resetClientVersion() {
this._apiVersion = API.defaultVersion;
this._tsserverVersion = undefined;