From a1da7709f8638b08d4c77fba86e3b7422ef0faea Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 18 Aug 2016 23:41:48 -0700 Subject: [PATCH] propagate debug/inspect flags to typingsInstaller process --- src/server/server.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index dc614fba1f7..2f98db89833 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -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();