propagate debug/inspect flags to typingsInstaller process

This commit is contained in:
Vladimir Matveev 2016-08-18 23:41:48 -07:00
parent 875e62cc75
commit a1da7709f8

View File

@ -183,9 +183,25 @@ namespace ts.server {
let args: string[] = [];
if (this.logger.loggingEnabled() && this.logger.getLogFileName()) {
args = [ "--logFile", combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`) ];
args.push("--logFile", combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`));
}
this.installer = childProcess.fork(combinePaths(__dirname, "typingsInstaller.js"), args);
let execArgv: string[] = [];
{
for (const arg of process.execArgv) {
const match = /^--(debug|inspect)(=(\d+))?$/.exec(arg);
if (match) {
// if port is specified - use port + 1
// otherwise pick a default port depending on if 'debug' or 'inspect' and use its value + 1
let currentPort = match[3] !== undefined
? +match[3]
: match[1] === "debug" ? 5858 : 9229;
execArgv.push(`--${match[1]}=${currentPort + 1}`);
break;
}
}
}
this.installer = childProcess.fork(combinePaths(__dirname, "typingsInstaller.js"), args, { execArgv });
this.installer.on("message", m => this.handleMessage(m));
process.on("exit", () => {
this.installer.kill();