From 84310c40d893d2160314a01ac80faeb77d31a9c1 Mon Sep 17 00:00:00 2001 From: DudaGod Date: Fri, 13 Sep 2024 15:36:42 +0300 Subject: [PATCH] fix: make error from swc/core shorter --- src/utils/typescript.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/typescript.ts b/src/utils/typescript.ts index 28a9abc8..a0fddc73 100644 --- a/src/utils/typescript.ts +++ b/src/utils/typescript.ts @@ -1,6 +1,10 @@ import _ from "lodash"; +import debug from "debug"; import logger from "./logger"; +const swcDebugNamespace = "testplane:swc"; +const swcDebugLog = debug(swcDebugNamespace); + export const tryToRegisterTsNode = (isSilent: boolean = false): void => { if (process.env.TS_ENABLE === "false") { return; @@ -37,7 +41,15 @@ export const tryToRegisterTsNode = (isSilent: boolean = false): void => { `testplane: you may install @swc/core for significantly faster reading of typescript tests.`, ); } else { - logger.warn(`testplane: could not load @swc/core:`, err); + const isSwcDebugLogEnabled = debug.enabled(swcDebugNamespace); + + if (isSwcDebugLogEnabled) { + swcDebugLog(err); + } else { + logger.warn( + `testplane: could not load @swc/core. Run Testplane with "DEBUG=testplane:swc" to see details.`, + ); + } } } }