Skip to content

Commit 6e0616c

Browse files
author
Artem
committed
fix encoding for human readable commands
1 parent 11506c2 commit 6e0616c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

redisinsight/api/src/modules/workbench/providers/workbench-commands.executor.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import {
66
ClusterNodeRole, ClusterSingleNodeOptions,
77
CommandExecutionStatus,
88
} from 'src/modules/cli/dto/cli.dto';
9-
import { checkRedirectionError, parseRedirectionError, splitCliCommandLine } from 'src/utils/cli-helper';
9+
import {
10+
checkHumanReadableCommands,
11+
checkRedirectionError,
12+
parseRedirectionError,
13+
splitCliCommandLine,
14+
} from 'src/utils/cli-helper';
1015
import {
1116
CommandNotSupportedError,
1217
CommandParsingError,
@@ -63,8 +68,10 @@ export class WorkbenchCommandsExecutor {
6368

6469
try {
6570
const [command, ...args] = splitCliCommandLine(commandLine);
71+
const replyEncoding = checkHumanReadableCommands(`${command} ${args[0]}`) ? 'utf8' : undefined;
72+
6673
const response = this.formatter.format(
67-
await this.redisTool.execCommand(clientOptions, command, args),
74+
await this.redisTool.execCommand(clientOptions, command, args, replyEncoding),
6875
);
6976

7077
this.logger.log('Succeed to execute workbench command.');
@@ -98,6 +105,7 @@ export class WorkbenchCommandsExecutor {
98105
this.logger.log(`Executing redis.cluster CLI command for single node ${JSON.stringify(nodeOptions)}`);
99106
try {
100107
const [command, ...args] = splitCliCommandLine(commandLine);
108+
const replyEncoding = checkHumanReadableCommands(`${command} ${args[0]}`) ? 'utf8' : undefined;
101109

102110
const nodeAddress = `${nodeOptions.host}:${nodeOptions.port}`;
103111
let result = await this.redisTool.execCommandForNode(
@@ -106,6 +114,7 @@ export class WorkbenchCommandsExecutor {
106114
args,
107115
role,
108116
nodeAddress,
117+
replyEncoding,
109118
);
110119
if (result.error && checkRedirectionError(result.error) && nodeOptions.enableRedirection) {
111120
const { slot, address } = parseRedirectionError(result.error);
@@ -115,6 +124,7 @@ export class WorkbenchCommandsExecutor {
115124
args,
116125
role,
117126
address,
127+
replyEncoding,
118128
);
119129
result.slot = parseInt(slot, 10);
120130
}
@@ -155,9 +165,10 @@ export class WorkbenchCommandsExecutor {
155165
this.logger.log(`Executing redis.cluster CLI command for [${role}] nodes.`);
156166
try {
157167
const [command, ...args] = splitCliCommandLine(commandLine);
168+
const replyEncoding = checkHumanReadableCommands(`${command} ${args[0]}`) ? 'utf8' : undefined;
158169

159170
return (
160-
await this.redisTool.execCommandForNodes(clientOptions, command, args, role)
171+
await this.redisTool.execCommandForNodes(clientOptions, command, args, role, replyEncoding)
161172
).map((nodeExecReply) => {
162173
const {
163174
response, status, host, port,

0 commit comments

Comments
 (0)