Skip to content

Commit

Permalink
Custom strip ansi and chalk (#25)
Browse files Browse the repository at this point in the history
* use custom strip-ansi function

* strip-ansi and chalk
  • Loading branch information
bameyrick authored Oct 3, 2024
1 parent 1b3e02f commit de83f1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ConcurrentCommand } from './command';
import { getName } from './get-name';
import { logError } from './log-error';
import { runCommand } from './run-command';
import { stripAnsi } from './strip-ansi';
import { stripAnsiAndChalk } from './strip-ansi-and-chalk';
import { WaitCondition } from './wait-condition';

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ export function concurrently(commands: ConcurrentCommand[], index = 0): void {
}
case WaitCondition.Includes: {
runCommand(command.command, index, name, command.longestName, message => {
if (!conditionMet && stripAnsi(message).toLowerCase().includes(command.value!.toLowerCase())) {
if (!conditionMet && stripAnsiAndChalk(message).toLowerCase().includes(command.value!.toLowerCase())) {
conditionMet = true;

concurrently(commands, nextIndex);
Expand All @@ -64,7 +64,7 @@ export function concurrently(commands: ConcurrentCommand[], index = 0): void {
}
case WaitCondition.Matches: {
runCommand(command.command, index, name, command.longestName, message => {
if (!conditionMet && stripAnsi(message) === command.value) {
if (!conditionMet && stripAnsiAndChalk(message) === command.value) {
conditionMet = true;

concurrently(commands, nextIndex);
Expand Down
5 changes: 5 additions & 0 deletions src/strip-ansi-and-chalk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import stripAnsi from 'strip-ansi';

Check failure on line 1 in src/strip-ansi-and-chalk.ts

View workflow job for this annotation

GitHub Actions / publish

Cannot find module 'strip-ansi' or its corresponding type declarations.

export function stripAnsiAndChalk(value: string): string {
return stripAnsi(value).replace(/\u001b[^m]*?m/g, '');
}

0 comments on commit de83f1b

Please sign in to comment.