Wanna see something cool? Check out Angular Spotify 🎧

nx:run-commands output not colored

Problem

We are using Nx in our project and recently we want to utlize nx:run-commands to run two commands:

  1. nx serve
  2. open a custom our configured domain

However, we found that the output of the command is not colored.

"serve-open": {
  "executor": "nx:run-commands",
  "options": {
    "commands": [
      "nx run my-bank:serve",
      "open https://our-custom-domain.local"
    ],
    "parallel": true
  }
}

nx run-commands output not colored

Solution

After visiting some related issues, we found that we need to set --output-style to whether stream or stream-without-prefixes

This 10918#issuecomment-1202731648 is the most helpful one.

"serve-open": {
  "executor": "nx:run-commands",
  "options": {
    "commands": [
-     "nx run my-bank:serve",
+     "nx run my-bank:serve --output-style=stream-without-prefixes",
      "open https://our-custom-domain.local"
    ],
    "parallel": true
  }
}

Now the output looks as expected:

nx run-commands output colored

Published 2 Mar 2023

    Read more

     — Prettier - prevent HTML closing tag > being placed on a new line?
     — zsh history not working after VSCode upgrade
     — The different between :focus and :focus-visible
     — Angular 13 upgrade - Error: Unknown keyword formatMinimum
     — Why Web Performance Matters: An Introduction