Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Colors in Angular CLI

The script that starts my Angular CLI development Web server produces almost illegible error messages, such as the following.[TypeScript Compiler Diagonstics]

I would much prefer something like this:[Legible Error Message

Before I start digging into the oodles of configuration files associated with my Angular/CLI installation, I thought that I would start by asking for directions.

like image 287
David A. Gray Avatar asked May 01 '17 23:05

David A. Gray


2 Answers

The easiest way to do it is to change characters in the output stream of the application that controls the color.

Linux bash:

ng serve | tr $INPUTCOLOR $OUTPUTCOLOR

or

ng serve | sed -r "s/$INPUTCOLOR/$OUTPUTCOLOR/g'

Windows PowerShell:

ng serve | ForEach-Object { $_ -replace $INPUTCOLOR, $OUTPUTCOLOR }

The $INPUTCOLOR and $OUTPUTCOLOR is needed to be set to run the code. This way every red foreground color can be changed with red background and white foreground color.

like image 89
androbin Avatar answered Sep 19 '22 06:09

androbin


You can achieve this by adding | %{$_ -replace "\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]",""} to the end of the command. For example:

ng build | %{$_ -replace "\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]",""}

Source: https://github.com/angular/angular-cli/issues/6478

like image 21
Casper Alant Avatar answered Sep 20 '22 06:09

Casper Alant