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
6.98k stars 227 forks source link

Feature request: Add or document API option to disable color output #466

Closed DavidBiesack closed 4 hours ago

DavidBiesack commented 6 months ago

The CLI contains a --no-color option, but the API options do not describe how to suppress color output (for example, if not connected to a tty). I don't want to pass colors: [ 'black' ], as that may not work if the user's terminal/console has a black/dark background. Consider a noColor: true option.

concurrently --no-color "echo 1" "echo 2" "echo 3"

There is a source code comment

        // This one is provided for free. Chalk reads this itself and removes colors.
        // https://www.npmjs.com/package/chalk#chalksupportscolor
        'no-color': {
            describe: 'Disables colors from logging',
            type: 'boolean',
        },

but that is cryptic at best; I don't know if that means I can use 'no-color' as an option in the prefixColors array

options.prefixColors = ['no-color'];

or something else (i.e. just omit prefixColors). If that is the intent, and there is no default prefixColors when using the API, please update the README to reflect this.

The Chalk doc implies one can use an environment variable FORCE_COLOR=0 (see https://www.npmjs.com/package/chalk#supportscolor -- the source comment link cited above may be wrong) to disable colors, but that may not work if concurrently passes a default set of colors.