Skip to content

Commit e857838

Browse files
committed
fix error
1 parent eb059af commit e857838

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/utils/cpUtils.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ export async function executeCommand(command: string, args: string[], options: c
2626
childProc.on("error", reject);
2727

2828
childProc.on("close", (code: number) => {
29-
if (code !== 0 || result.indexOf("ERROR") > -1) {
29+
30+
var try_result_json;
31+
try {
32+
try_result_json = JSON.parse(result);
33+
} catch (e) {
34+
try_result_json;
35+
}
36+
if (code !== 0 || (try_result_json ? try_result_json.code < 0 : (result.indexOf("ERROR") > -1))) {
3037
const error: IExecError = new Error(`Command "${command} ${args.toString()}" failed with exit code "${code}".`);
3138
if (result) {
3239
error.result = result; // leetcode-cli may print useful content by exit with error code

0 commit comments

Comments
 (0)