Skip to content

Commit 81529a9

Browse files
authored
fix(suggestion): prefixColors API type to embrace string type (#439)
1 parent 1618208 commit 81529a9

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ For more details, visit https://github.com/open-cli-tools/concurrently
335335
- `prefix`: the prefix type to use when logging processes output.
336336
Possible values: `index`, `pid`, `time`, `command`, `name`, `none`, or a template (eg `[{time} process: {pid}]`).
337337
Default: the name of the process, or its index if no name is set.
338-
- `prefixColors`: a list of colors as supported by [chalk](https://www.npmjs.com/package/chalk) or `auto` for an automatically picked color.
338+
- `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.
339339
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.
340340
Prefix colors specified per-command take precedence over this list.
341341
- `prefixLength`: how many characters to show when prefixing with `command`. Default: `10`

src/concurrently.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,22 @@ export type ConcurrentlyOptions = {
6262
group?: boolean;
6363

6464
/**
65-
* Comma-separated list of chalk colors to use on prefixes.
65+
* A comma-separated list of chalk colors or a string for available styles listed below to use on prefixes.
66+
* If there are more commands than colors, the last color will be repeated.
67+
*
68+
* Available modifiers:
69+
* - `reset`, `bold`, `dim`, `italic`, `underline`, `inverse`, `hidden`, `strikethrough`
70+
*
71+
* Available colors:
72+
* - `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`,
73+
* any hex values for colors (e.g. `#23de43`) or `auto` for an automatically picked color
74+
*
75+
* Available background colors:
76+
* - `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite`
77+
*
78+
* @see {@link https://www.npmjs.com/package/chalk} for more information.
6679
*/
67-
prefixColors?: string[];
80+
prefixColors?: string | string[];
6881

6982
/**
7083
* Maximum number of commands to run at once.

src/prefix-color-selector.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ function* createColorGenerator(customColors: string[]): Generator<string, string
5858
export class PrefixColorSelector {
5959
private colorGenerator: Generator<string, string>;
6060

61-
constructor(customColors: string[] = []) {
62-
this.colorGenerator = createColorGenerator(customColors);
61+
constructor(customColors: string | string[] = []) {
62+
const normalizedColors = typeof customColors === 'string' ? [customColors] : customColors;
63+
this.colorGenerator = createColorGenerator(normalizedColors);
6364
}
6465

6566
/** A list of colors that are readable in a terminal. */

0 commit comments

Comments
 (0)