From 4b8cdd35c481e526dfa0dec1c05da0ce16526b51 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 15 Sep 2023 15:37:26 +0800 Subject: [PATCH] fix(core): should not print extra logs when press Ctrl+C (#4661) --- .changeset/four-beds-glow.md | 7 +++++++ packages/cli/core/src/createCli.ts | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/four-beds-glow.md diff --git a/.changeset/four-beds-glow.md b/.changeset/four-beds-glow.md new file mode 100644 index 000000000000..63a0cb2bbe93 --- /dev/null +++ b/.changeset/four-beds-glow.md @@ -0,0 +1,7 @@ +--- +'@modern-js/core': patch +--- + +fix(core): should not print extra logs when press Ctrl+C + +fix(core): 修复按下 press Ctrl+C 时会打印多余日志的问题 diff --git a/packages/cli/core/src/createCli.ts b/packages/cli/core/src/createCli.ts index e24f9ecbe42f..ebb419989d88 100644 --- a/packages/cli/core/src/createCli.ts +++ b/packages/cli/core/src/createCli.ts @@ -99,7 +99,10 @@ export const createCli = () => { hooksRunner.beforeExit(); if (err instanceof Error) { logger.error(err.stack); - } else { + } else if ( + err && + (event === 'unhandledRejection' || event === 'uncaughtException') + ) { // We should not pass it, if err is not instanceof Error. // We can use `console.trace` to follow it call stack, console.trace('Unknown Error', err);