open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
7k stars 228 forks source link

No colors for prefixes when using `prefixColors: "auto"` via concurrent API #437

Closed OnkelTem closed 1 year ago

OnkelTem commented 1 year ago

concurrently: 8.2.1 node: v16.17.0

I use the following script to run concurrent processes:

const fs = require('fs')
const path = require('path')
const concurrently = require('concurrently')

const workspacePaths = JSON.parse(fs.readFileSync('./package.json')).workspaces

const { result } = concurrently(
  workspacePaths.map((wp) => ({
    command: 'npm:dev',
    name: path.basename(wp),
    cwd: path.resolve(__dirname, '../', wp),
  })),
  {
    prefix: 'name',
    killOthers: ['failure', 'success'],
    restartTries: 0,
    prefixColors: 'auto',
  }
)

result.then(
  () => {
    console.log('Success')
  },
  () => {
    console.log('Failed')
  }
)

However, when I run in the terminal, it doesn't show any colors in the prefixes:

image

yet other colors are displayed. What could be the problem?

Thanks in advance.

SeiwonPark commented 1 year ago

Check out API's prefixColors. It says

Docs

prefixColors: a list of colors as supported by chalk or auto for an automatically picked color.

Definition

prefixColors?: string[]


So change it to

prefixColors: ['auto'],
paescuj commented 1 year ago

I think @SeiwonPark is right! (Thanks!) Therefore I'm closing this issue for now, but let me know if that doesn't work either and we'll reopen it.

OnkelTem commented 11 months ago

Thanks @SeiwonPark

However, an update to the docs was made:

prefixColors: a list of colors or a string as supported by chalk and additional style auto for an automatically picked color.

And I support it. Now it sounds much better.