(rawOptions: CreateOptions)
| 57 | |
| 58 | /** @internal */ |
| 59 | export function findAndReadConfig(rawOptions: CreateOptions) { |
| 60 | const cwd = resolve( |
| 61 | rawOptions.cwd ?? rawOptions.dir ?? DEFAULTS.cwd ?? process.cwd() |
| 62 | ); |
| 63 | const compilerName = rawOptions.compiler ?? DEFAULTS.compiler; |
| 64 | |
| 65 | // Compute minimum options to read the config file. |
| 66 | let projectLocalResolveDir = getBasePathForProjectLocalDependencyResolution( |
| 67 | undefined, |
| 68 | rawOptions.projectSearchDir, |
| 69 | rawOptions.project, |
| 70 | cwd |
| 71 | ); |
| 72 | let { compiler, ts } = resolveAndLoadCompiler( |
| 73 | compilerName, |
| 74 | projectLocalResolveDir |
| 75 | ); |
| 76 | |
| 77 | // Read config file and merge new options between env and CLI options. |
| 78 | const { configFilePath, config, tsNodeOptionsFromTsconfig, optionBasePaths } = |
| 79 | readConfig(cwd, ts, rawOptions); |
| 80 | |
| 81 | const options = assign<RegisterOptions>( |
| 82 | {}, |
| 83 | DEFAULTS, |
| 84 | tsNodeOptionsFromTsconfig || {}, |
| 85 | { optionBasePaths }, |
| 86 | rawOptions |
| 87 | ); |
| 88 | options.require = [ |
| 89 | ...(tsNodeOptionsFromTsconfig.require || []), |
| 90 | ...(rawOptions.require || []), |
| 91 | ]; |
| 92 | |
| 93 | // Re-resolve the compiler in case it has changed. |
| 94 | // Compiler is loaded relative to tsconfig.json, so tsconfig discovery may cause us to load a |
| 95 | // different compiler than we did above, even if the name has not changed. |
| 96 | if (configFilePath) { |
| 97 | projectLocalResolveDir = getBasePathForProjectLocalDependencyResolution( |
| 98 | configFilePath, |
| 99 | rawOptions.projectSearchDir, |
| 100 | rawOptions.project, |
| 101 | cwd |
| 102 | ); |
| 103 | ({ compiler } = resolveCompiler( |
| 104 | options.compiler, |
| 105 | optionBasePaths.compiler ?? projectLocalResolveDir |
| 106 | )); |
| 107 | } |
| 108 | |
| 109 | return { |
| 110 | options, |
| 111 | config, |
| 112 | projectLocalResolveDir, |
| 113 | optionBasePaths, |
| 114 | configFilePath, |
| 115 | cwd, |
| 116 | compiler, |
no test coverage detected
searching dependent graphs…