Skip to content

Commit dbd5952

Browse files
ceottakiZhicheng Wang
authored and
Zhicheng Wang
committed
fix(@angular/cli): Headless win32 now works as expected (angular#4871)
When running in a headless process in win32 the lack of process.stdin throws an error. Fixes angular#4870
1 parent fb37dbe commit dbd5952

File tree

1 file changed

+11
-1
lines changed
  • packages/@angular/cli/bin

1 file changed

+11
-1
lines changed

packages/@angular/cli/bin/ng

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const resolve = require('resolve');
1414
const stripIndents = require('common-tags').stripIndents;
1515
const yellow = require('chalk').yellow;
1616
const SemVer = require('semver').SemVer;
17+
const events = require('events');
1718

1819

1920
function _fromPackageJson(cwd) {
@@ -132,9 +133,18 @@ resolve('@angular/cli', { basedir: process.cwd() },
132133
cli = cli['default'];
133134
}
134135

136+
let standardInput;
137+
try {
138+
standardInput = process.stdin;
139+
} catch (e) {
140+
delete process.stdin;
141+
process.stdin = new events.EventEmitter();
142+
standardInput = process.stdin;
143+
}
144+
135145
cli({
136146
cliArgs: process.argv.slice(2),
137-
inputStream: process.stdin,
147+
inputStream: standardInput,
138148
outputStream: process.stdout
139149
}).then(function (result) {
140150
process.exit(typeof result === 'object' ? result.exitCode : result);

0 commit comments

Comments
 (0)