Skip to content

Commit

Permalink
fix(suggestion): prefixColors API type to embrace string type (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
seiwonpark authored Sep 23, 2023
1 parent 1618208 commit 81529a9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
17 changes: 15 additions & 2 deletions src/concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions src/prefix-color-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ function* createColorGenerator(customColors: string[]): Generator<string, string
export class PrefixColorSelector {
private colorGenerator: Generator<string, string>;

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. */
Expand Down

0 comments on commit 81529a9

Please sign in to comment.