From 11a67d416c9e75cff8ebfe597d1e0f7f58ff1acb Mon Sep 17 00:00:00 2001 From: xel23 Date: Mon, 8 Feb 2021 14:40:17 +0300 Subject: [PATCH] fix(config): check extension before ts-node register 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