From 474f4e1caff469cce87f19a11d9179e4e05552f9 Mon Sep 17 00:00:00 2001 From: xel23 Date: Fri, 12 Feb 2021 20:35:46 +0300 Subject: [PATCH] fix(config): check extension before ts-node register (#3651) Call require('ts-node').register() after checking configFilePath has `.ts` extension Fixes #3329 --- lib/config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/config.js b/lib/config.js index b08bbde7d..30e874ee6 100644 --- a/lib/config.js +++ b/lib/config.js @@ -27,7 +27,7 @@ try { } catch (e) {} try { - require('ts-node').register() + require('ts-node') TYPE_SCRIPT_AVAILABLE = true } catch (e) {} @@ -374,6 +374,9 @@ function parseConfig (configFilePath, cliOptions, parseOptions) { let configModule if (configFilePath) { try { + if (path.extname(configFilePath) === '.ts' && TYPE_SCRIPT_AVAILABLE) { + require('ts-node').register() + } configModule = require(configFilePath) if (typeof configModule === 'object' && typeof configModule.default !== 'undefined') { configModule = configModule.default