From 5ef344785c4dd0906c8dd366850305bd5373f5e0 Mon Sep 17 00:00:00 2001 From: Roman Kuznetsov Date: Fri, 10 Nov 2023 15:52:13 +0300 Subject: [PATCH] fix: log an error while trying to register ts-node --- src/utils/typescript.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/utils/typescript.ts b/src/utils/typescript.ts index d7445f75c..09b0af1df 100644 --- a/src/utils/typescript.ts +++ b/src/utils/typescript.ts @@ -18,10 +18,19 @@ export const tryToRegisterTsNode = (): void => { swc = true; } catch {} // eslint-disable-line no-empty - register({ - skipProject: JSON.parse(process.env.TS_NODE_SKIP_PROJECT ?? "true"), - transpileOnly: JSON.parse(process.env.TS_NODE_TRANSPILE_ONLY ?? "true"), - swc: JSON.parse(process.env.TS_NODE_SWC ?? swc.toString()), - }); + const skipProjectRaw = process.env.TS_NODE_SKIP_PROJECT ?? "true"; + const transpileOnlyRaw = process.env.TS_NODE_TRANSPILE_ONLY ?? "true"; + const swcRaw = process.env.TS_NODE_SWC ?? swc.toString(); + + try { + register({ + skipProject: JSON.parse(skipProjectRaw), + transpileOnly: JSON.parse(transpileOnlyRaw), + swc: JSON.parse(swcRaw), + }); + } catch (err) { + const params = `swc: "${swcRaw}", transpileOnly: "${transpileOnlyRaw}", skipProject: "${skipProjectRaw}"`; + console.error(`hermione: an error occured while trying to register ts-node (${params}):`, err); + } } catch {} // eslint-disable-line no-empty };