* Load TypeScript configuration.
(configFileName: string)
| 377 | * Load TypeScript configuration. |
| 378 | */ |
| 379 | function readConfig(configFileName: string): _ts.ParsedCommandLine { |
| 380 | let config: any = { compilerOptions: {} }; |
| 381 | const basePath = normalizeSlashes(dirname(configFileName)); |
| 382 | |
| 383 | // Read project configuration when available. |
| 384 | if (configFileName) { |
| 385 | const result = ts.readConfigFile(configFileName, readFile); |
| 386 | |
| 387 | // Return diagnostics. |
| 388 | if (result.error) { |
| 389 | const errorResult = { |
| 390 | errors: [result.error], |
| 391 | fileNames: [], |
| 392 | options: {}, |
| 393 | }; |
| 394 | const configDiagnosticList = filterDiagnostics( |
| 395 | errorResult.errors, |
| 396 | ignoreDiagnostics |
| 397 | ); |
| 398 | // Render the configuration errors. |
| 399 | reportTSError(configDiagnosticList, true); |
| 400 | return errorResult; |
| 401 | } |
| 402 | |
| 403 | config = result.config; |
| 404 | } |
| 405 | |
| 406 | // Remove resolution of "files". |
| 407 | if (!options.files) { |
| 408 | config.files = []; |
| 409 | config.include = []; |
| 410 | } |
| 411 | |
| 412 | // Override default configuration options `ts-node` requires. |
| 413 | config.compilerOptions = Object.assign( |
| 414 | {}, |
| 415 | config.compilerOptions, |
| 416 | options.compilerOptions, |
| 417 | TS_NODE_COMPILER_OPTIONS |
| 418 | ); |
| 419 | |
| 420 | fixConfig(config, options.nodeVersionMajor); |
| 421 | |
| 422 | const configResult = ts.parseJsonConfigFileContent( |
| 423 | config, |
| 424 | ts.sys, |
| 425 | basePath, |
| 426 | undefined, |
| 427 | configFileName |
| 428 | ); |
| 429 | |
| 430 | if (configFileName) { |
| 431 | const configDiagnosticList = filterDiagnostics( |
| 432 | configResult.errors, |
| 433 | ignoreDiagnostics |
| 434 | ); |
| 435 | // Render the configuration errors. |
| 436 | reportTSError(configDiagnosticList, configResult.options.noEmitOnError); |
no test coverage detected