Skip to content

Commit

Permalink
fix(config): check extension before ts-node register (karma-runner#3651)
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 authored and anthony-redFox committed May 5, 2023
1 parent e948f12 commit a77b1de
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 a77b1de

Please sign in to comment.