Skip to content

Commit

Permalink
fix(config): check extension before ts-node register
Browse files Browse the repository at this point in the history
Call require('ts-node').register() after checking configFilePath has `.ts` extension

Fixes karma-runner#3329
  • Loading branch information
xel23 committed Feb 8, 2021
1 parent 7ab86be commit 11a67d4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ try {
} catch (e) {}

try {
require('ts-node').register()
require('ts-node')
TYPE_SCRIPT_AVAILABLE = true
} catch (e) {}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 11a67d4

Please sign in to comment.