From 708caf9a7262e71d560afc4c78580a4fd09adeaf Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 13 Mar 2018 11:03:12 -0700 Subject: [PATCH] Do not use unguarded process in tsc.ts --- src/compiler/sys.ts | 6 ++++++ src/compiler/tsc.ts | 7 ++++--- .../user/TypeScript-Node-Starter/TypeScript-Node-Starter | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 4f62cfdfe2d..f613a2fc927 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -456,6 +456,7 @@ namespace ts { setTimeout?(callback: (...args: any[]) => void, ms: number, ...args: any[]): any; clearTimeout?(timeoutId: any): void; clearScreen?(): void; + /*@internal*/ setBlocking?(): void; } export interface FileWatcher { @@ -614,6 +615,11 @@ namespace ts { clearTimeout, clearScreen: () => { process.stdout.write("\x1Bc"); + }, + setBlocking: () => { + if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) { + process.stdout._handle.setBlocking(true); + } } }; return nodeSystem; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 3a340f049f8..04725cebabe 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -399,8 +399,9 @@ if (ts.Debug.isDebugging) { if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) { ts.sys.tryEnableSourceMapsForHost(); } -declare var process: any; -if (process && process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) { - process.stdout._handle.setBlocking(true); + +if (ts.sys.setBlocking) { + ts.sys.setBlocking(); } + ts.executeCommandLine(ts.sys.args); diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index ed149eb0c78..40bdb4eadab 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit ed149eb0c787b1195a95b44105822c64bb6eb636 +Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6