diff --git a/README.md b/README.md index 814e6551..1f92edd9 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,7 @@ For more details, visit https://github.com/open-cli-tools/concurrently - `prefix`: the prefix type to use when logging processes output. Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`). Default: the name of the process, or its index if no name is set. - - `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk) or `auto` for an automatically picked color. + - `prefixColors`: a list of colors or a string as supported by [chalk](https://www.npmjs.com/package/chalk) and additional style `auto` for an automatically picked color. If concurrently would run more commands than there are colors, the last color is repeated, unless if the last color value is `auto` which means following colors are automatically picked to vary. Prefix colors specified per-command take precedence over this list. - `prefixLength`: how many characters to show when prefixing with `command`. Default: `10` diff --git a/src/concurrently.ts b/src/concurrently.ts index ad3f8f7d..2c5b9ec8 100644 --- a/src/concurrently.ts +++ b/src/concurrently.ts @@ -62,9 +62,22 @@ export type ConcurrentlyOptions = { group?: boolean; /** - * Comma-separated list of chalk colors to use on prefixes. + * A comma-separated list of chalk colors or a string for available styles listed below to use on prefixes. + * If there are more commands than colors, the last color will be repeated. + * + * Available modifiers: + * - `reset`, `bold`, `dim`, `italic`, `underline`, `inverse`, `hidden`, `strikethrough` + * + * Available colors: + * - `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`, + * any hex values for colors (e.g. `#23de43`) or `auto` for an automatically picked color + * + * Available background colors: + * - `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite` + * + * @see {@link https://www.npmjs.com/package/chalk} for more information. */ - prefixColors?: string[]; + prefixColors?: string | string[]; /** * Maximum number of commands to run at once. diff --git a/src/prefix-color-selector.ts b/src/prefix-color-selector.ts index 092b5e02..63ae0727 100644 --- a/src/prefix-color-selector.ts +++ b/src/prefix-color-selector.ts @@ -58,8 +58,9 @@ function* createColorGenerator(customColors: string[]): Generator; - constructor(customColors: string[] = []) { - this.colorGenerator = createColorGenerator(customColors); + constructor(customColors: string | string[] = []) { + const normalizedColors = typeof customColors === 'string' ? [customColors] : customColors; + this.colorGenerator = createColorGenerator(normalizedColors); } /** A list of colors that are readable in a terminal. */