File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -91,12 +91,22 @@ export const emitterMessage = Type.Union(
91
91
92
92
export type EmitterMessage = Static < typeof emitterMessage >
93
93
94
+ // eslint-disable-next-line no-control-regex
95
+ const ANSI_ESCAPE = / \x1b \[ [ 0 - 9 ; ] * m / g;
96
+
97
+ function removeAnsiColorCodes ( str : string ) :string {
98
+ return str . replace ( ANSI_ESCAPE , "" ) ;
99
+ }
100
+
94
101
export const prepareRedisListeners = ( ) => {
95
102
const redisSubscriptionClient = new RedisClient ( )
96
103
redisSubscriptionClient . client . subscribe ( "emitter" )
97
104
redisSubscriptionClient . client . on ( "message" , ( channel , message ) => {
98
105
if ( channel === "emitter" ) {
99
106
const body = JSON . parse ( message . toString ( ) ) as EmitterMessage
107
+ if ( body . type === "serverLog" ) {
108
+ body . payload . message = removeAnsiColorCodes ( body . payload . message )
109
+ }
100
110
emitter . emit ( body . type , body . payload )
101
111
}
102
112
} )
You can’t perform that action at this time.
0 commit comments