Skip to content

Commit

Permalink
fix: when running in a headless process in win32 the lack of process.…
Browse files Browse the repository at this point in the history
…stdin throws an error.

Fix angular#4870
  • Loading branch information
ceottaki committed Feb 21, 2017
1 parent a4b43a5 commit fed0b59
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 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,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);
Expand Down

0 comments on commit fed0b59

Please sign in to comment.