Skip to content

Commit 1374d75

Browse files
authored
Merge pull request #130 from wp-cli/fix/strip-ansi-colors-on-string-comparison
Strip ANSI colors on string comparison
2 parents 2668bf5 + deb529b commit 1374d75

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Context/Support.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ protected function assert_not_numeric( $actual ) {
5151
}
5252

5353
protected function check_string( $output, $expected, $action, $message = false ) {
54+
// Strip ANSI color codes before comparing strings.
55+
$output = preg_replace( '/\e[[][A-Za-z0-9];?[0-9]*m?/', '', $output );
56+
5457
switch ( $action ) {
5558
case 'be':
5659
$r = rtrim( $output, "\n" ) === $expected;

0 commit comments

Comments
 (0)