Charles Lyding 2334a7c030 fix(@angular/cli): use recommended TTY check logic
`stdin` can be redirected/piped by various shells but still be interactive.  Node.js recommends only testing `stdout`: https://nodejs.org/api/tty.html#tty_tty

Fixes #14640
2019-06-06 14:28:36 -07:00

18 lines
504 B
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
export function isTTY(): boolean {
const force = process.env['NG_FORCE_TTY'];
if (force !== undefined) {
return !(force === '0' || force.toUpperCase() === 'FALSE');
}
const ci = process.env['CI'];
return !!process.stdout.isTTY && (!ci || ci === '0' || ci.toUpperCase() === 'FALSE');
}