From 6e28463bc87215191c078fbda087f7f6e3da57d4 Mon Sep 17 00:00:00 2001 From: Felipe Ceotto Date: Tue, 21 Feb 2017 12:17:10 +0000 Subject: [PATCH] fix: when running in a headless process in win32 the lack of process.stdin throws an error. --- 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 a0c4536..336ef56 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); -- 1.9.5.msysgit.0