From fed0b59d3d1197ca1df4235dad157d068959b9a7 Mon Sep 17 00:00:00 2001 From: Felipe Ceotto Date: Tue, 21 Feb 2017 12:23:59 +0000 Subject: [PATCH 1/2] fix: when running in a headless process in win32 the lack of process.stdin throws an error. Fix #4870 --- packages/@angular/cli/bin/ng | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/@angular/cli/bin/ng b/packages/@angular/cli/bin/ng index a0c453630b96..336ef56fbb84 100755 --- a/packages/@angular/cli/bin/ng +++ b/packages/@angular/cli/bin/ng @@ -14,6 +14,7 @@ const resolve = require('resolve'); const stripIndents = require('common-tags').stripIndents; const yellow = require('chalk').yellow; const SemVer = require('semver').SemVer; +const events = require('events'); function _fromPackageJson(cwd) { @@ -132,9 +133,20 @@ resolve('@angular/cli', { basedir: process.cwd() }, cli = cli['default']; } + let standardInput; + if (process.platform === 'win32') { + try { + standardInput = process.stdin; + } catch (e) { + delete process.stdin; + process.stdin = new events.EventEmitter(); + standardInput = process.stdin; + } + } + cli({ cliArgs: process.argv.slice(2), - inputStream: process.stdin, + inputStream: standardInput, outputStream: process.stdout }).then(function (result) { process.exit(typeof result === 'object' ? result.exitCode : result); From fe51b9b356ed8b6eec6ec12b8222a9fbe644562b Mon Sep 17 00:00:00 2001 From: Felipe Ceotto Date: Wed, 22 Feb 2017 08:30:32 +0000 Subject: [PATCH 2/2] Fix: inputStream would not be set in linux and mac os x... ...due to a bug introduced by previous commit. --- packages/@angular/cli/bin/ng | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/@angular/cli/bin/ng b/packages/@angular/cli/bin/ng index 336ef56fbb84..029c758c8cf0 100755 --- a/packages/@angular/cli/bin/ng +++ b/packages/@angular/cli/bin/ng @@ -134,14 +134,12 @@ resolve('@angular/cli', { basedir: process.cwd() }, } let standardInput; - if (process.platform === 'win32') { - try { - standardInput = process.stdin; - } catch (e) { - delete process.stdin; - process.stdin = new events.EventEmitter(); - standardInput = process.stdin; - } + try { + standardInput = process.stdin; + } catch (e) { + delete process.stdin; + process.stdin = new events.EventEmitter(); + standardInput = process.stdin; } cli({