Skip to content

Commit 91c18ce

Browse files
imhoffdfilipesilva
authored andcommitted
feat(@angular-devkit/core): respect FORCE_COLOR env var behavior
Currently, there is no mechanism in the Angular tooling to forcefully output colors regardless of detected terminal capabilities. This commit adds an override via an environment variable: `FORCE_COLOR`. The behavior in this commit is the same as the behavior in a commonly used module, `supports-color` (https://github.com/chalk/supports-color#info). This is especially useful when piping output from the Angular CLI, which would automatically and irreversibly disable colors before this commit.
1 parent 37072fb commit 91c18ce

File tree

1 file changed

+8
-1
lines changed
  • packages/angular_devkit/core/src/terminal

1 file changed

+8
-1
lines changed

packages/angular_devkit/core/src/terminal/caps.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,15 @@ export interface StreamCapabilities {
7575

7676
const ciVars = ['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'];
7777

78+
function _getColorLevel(stream: Socket): 0 | 1 | 2 | 3 {
79+
if ('FORCE_COLOR' in _env) {
80+
if (_env.FORCE_COLOR === '1') {
81+
return 3;
82+
} else if (_env.FORCE_COLOR === '0') {
83+
return 0;
84+
}
85+
}
7886

79-
function _getColorLevel(stream: Socket): number {
8087
if (stream && !stream.isTTY) {
8188
return 0;
8289
}

0 commit comments

Comments
 (0)