From 803083d23cc9079cc9781790a293ae492fd532c6 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 16 Mar 2021 18:25:11 +0800 Subject: [PATCH] refactor: 1 --- packages/core/executor/src/index.js | 11 ++++++----- packages/core/executor/src/trace.js | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/core/executor/src/index.js b/packages/core/executor/src/index.js index 90f03e81..5f74a62d 100644 --- a/packages/core/executor/src/index.js +++ b/packages/core/executor/src/index.js @@ -88,15 +88,16 @@ export class Executor { logger.info('任务完成') trace.print() const result = resultTrace.get({ }) - const returnData = { + if (result) { + if (result.status === 'error' && options.args.doNotThrowError === false) { + throw new Error(result.remark) + } + } + return { cert, context, result } - if (result.status === 'error' && options.args.doNotThrowError === false) { - throw new Error(result.remark) - } - return returnData } async runCertd (certd) { diff --git a/packages/core/executor/src/trace.js b/packages/core/executor/src/trace.js index 165b5e02..209f89d4 100644 --- a/packages/core/executor/src/trace.js +++ b/packages/core/executor/src/trace.js @@ -76,7 +76,9 @@ export class Trace { } } const result = this.get({ type: 'result' }) - this.printTraceLine(result, 'result', '') + if (result) { + this.printTraceLine(result, 'result', '') + } const mainContext = {} _.merge(mainContext, context) delete mainContext.__trace__