Skip to content

Commit e7e99f7

Browse files
committed
fix: fix runcmdEx error when command has no output
1 parent 020b47f commit e7e99f7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/legacy/api/CommandAPI.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ Local<Value> McClass::runcmdEx(const Arguments& args) {
196196
for (auto msg : output.getMessages()) {
197197
outputStr = outputStr.append(I18n::get(msg.getMessageId(), msg.getParams())).append("\n");
198198
}
199-
outputStr.erase(outputStr.size() - 1, 1);
199+
if (output.getMessages().size()) {
200+
outputStr.pop_back();
201+
}
200202
Local<Object> resObj = Object::newObject();
201203
resObj.set("success", output.getSuccessCount() ? true : false);
202204
resObj.set("output", outputStr);

0 commit comments

Comments
 (0)