Skip to content

Commit

Permalink
fix(@angular/cli): Headless win32 now works as expected (#4871)
Browse files Browse the repository at this point in the history
When running in a headless process in win32 the lack of process.stdin throws an error.

Fixes #4870
  • Loading branch information
ceottaki authored and hansl committed Feb 22, 2017
1 parent ade2236 commit 4af7a42
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/@angular/cli/bin/ng
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -132,9 +133,18 @@ resolve('@angular/cli', { basedir: process.cwd() },
cli = cli['default'];
}

let standardInput;
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);
Expand Down

0 comments on commit 4af7a42

Please sign in to comment.