( cwd: string, ts: TSCommon, rawApiOptions: CreateOptions )
| 127 | * @internal |
| 128 | */ |
| 129 | export function readConfig( |
| 130 | cwd: string, |
| 131 | ts: TSCommon, |
| 132 | rawApiOptions: CreateOptions |
| 133 | ): { |
| 134 | /** |
| 135 | * Path of tsconfig file if one was loaded |
| 136 | */ |
| 137 | configFilePath: string | undefined; |
| 138 | /** |
| 139 | * Parsed TypeScript configuration with compilerOptions merged from all other sources (env vars, etc) |
| 140 | */ |
| 141 | config: _ts.ParsedCommandLine; |
| 142 | /** |
| 143 | * ts-node options pulled from `tsconfig.json`, NOT merged with any other sources. Merging must happen outside |
| 144 | * this function. |
| 145 | */ |
| 146 | tsNodeOptionsFromTsconfig: TsConfigOptions; |
| 147 | optionBasePaths: OptionBasePaths; |
| 148 | } { |
| 149 | // Ordered [a, b, c] where config a extends b extends c |
| 150 | const configChain: Array<{ |
| 151 | config: any; |
| 152 | basePath: string; |
| 153 | configPath: string; |
| 154 | }> = []; |
| 155 | let config: any = { compilerOptions: {} }; |
| 156 | let basePath = cwd; |
| 157 | let configFilePath: string | undefined = undefined; |
| 158 | const projectSearchDir = resolve(cwd, rawApiOptions.projectSearchDir ?? cwd); |
| 159 | |
| 160 | const { |
| 161 | fileExists = ts.sys.fileExists, |
| 162 | readFile = ts.sys.readFile, |
| 163 | skipProject = DEFAULTS.skipProject, |
| 164 | project = DEFAULTS.project, |
| 165 | tsTrace = DEFAULTS.tsTrace, |
| 166 | } = rawApiOptions; |
| 167 | |
| 168 | // Read project configuration when available. |
| 169 | if (!skipProject) { |
| 170 | if (project) { |
| 171 | const resolved = resolve(cwd, project); |
| 172 | const nested = join(resolved, 'tsconfig.json'); |
| 173 | configFilePath = fileExists(nested) ? nested : resolved; |
| 174 | } else { |
| 175 | configFilePath = ts.findConfigFile(projectSearchDir, fileExists); |
| 176 | } |
| 177 | |
| 178 | if (configFilePath) { |
| 179 | let pathToNextConfigInChain = configFilePath; |
| 180 | const tsInternals = createTsInternals(ts); |
| 181 | const errors: Array<_ts.Diagnostic> = []; |
| 182 | |
| 183 | // Follow chain of "extends" |
| 184 | while (true) { |
| 185 | const result = ts.readConfigFile(pathToNextConfigInChain, readFile); |
| 186 |
no test coverage detected
searching dependent graphs…