Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cli/prefixing.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ $ concurrently -c red,blue 'echo Hello there' 'echo General Kenobi!'
Colors can take modifiers too. Several can be applied at once by prepending `.<modifier 1>.<modifier 2>` and so on.

```bash
$ concurrently -c red,bold.blue.dim 'echo Hello there' 'echo General Kenobi!'
$ concurrently -c '#23de43.inverse,bold.blue.dim' 'echo Hello there' 'echo General Kenobi!'
```

<details>
Expand Down
15 changes: 15 additions & 0 deletions src/logger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ describe('#logCommandText()', () => {
expect(logger.log).toHaveBeenCalledWith(chalk.hex(prefixColor)('[1]') + ' ', 'foo', cmd);
});

it('logs prefix using prefixColor from command if prefixColor is a hex value with modifiers', () => {
const { logger } = createLogger({});
const prefixColor = '#32bd8a.inverse';
const cmd = new FakeCommand('', undefined, 1, {
prefixColor,
});
logger.logCommandText('foo', cmd);

expect(logger.log).toHaveBeenCalledWith(
chalk.hex(prefixColor).inverse('[1]') + ' ',
'foo',
cmd,
);
});

it('does nothing if command is hidden by name', () => {
const { logger } = createLogger({ hide: ['abc'] });
const cmd = new FakeCommand('abc');
Expand Down
7 changes: 6 additions & 1 deletion src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ export class Logger {
colorText(command: Command, text: string) {
let color: chalk.Chalk;
if (command.prefixColor?.startsWith('#')) {
color = this.chalk.hex(command.prefixColor);
const [hexColor, ...modifiers] = command.prefixColor.split('.');
color = this.chalk.hex(hexColor);
const modifiedColor = getChalkPath(color, modifiers.join('.'));
if (modifiedColor) {
color = modifiedColor;
}
} else {
const defaultColor = getChalkPath(this.chalk, defaults.prefixColors) as Chalk;
color = getChalkPath(this.chalk, command.prefixColor ?? '') ?? defaultColor;
Expand Down
Loading