Skip to content

Commit 474f4e1

Browse files
authoredFeb 12, 2021
fix(config): check extension before ts-node register (#3651)
Call require('ts-node').register() after checking configFilePath has `.ts` extension Fixes #3329
1 parent 7ab86be commit 474f4e1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎lib/config.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ try {
2727
} catch (e) {}
2828

2929
try {
30-
require('ts-node').register()
30+
require('ts-node')
3131
TYPE_SCRIPT_AVAILABLE = true
3232
} catch (e) {}
3333

@@ -374,6 +374,9 @@ function parseConfig (configFilePath, cliOptions, parseOptions) {
374374
let configModule
375375
if (configFilePath) {
376376
try {
377+
if (path.extname(configFilePath) === '.ts' && TYPE_SCRIPT_AVAILABLE) {
378+
require('ts-node').register()
379+
}
377380
configModule = require(configFilePath)
378381
if (typeof configModule === 'object' && typeof configModule.default !== 'undefined') {
379382
configModule = configModule.default

0 commit comments

Comments
 (0)
Please sign in to comment.