| 201 | } |
| 202 | |
| 203 | const readTSConfig = (fileName: string): Effect.Effect< |
| 204 | { readonly [x: string]: unknown }, |
| 205 | never, |
| 206 | Path.Path | Domain.Process |
| 207 | > => |
| 208 | Effect.gen(function*() { |
| 209 | const path = yield* Path.Path |
| 210 | const process = yield* Domain.Process |
| 211 | const cwd = yield* process.cwd |
| 212 | return yield* pipe( |
| 213 | Effect.tryPromise(() => tsconfck.parse(path.resolve(cwd, fileName))).pipe( |
| 214 | Effect.map(({ tsconfig }) => tsconfig.compilerOptions ?? defaultCompilerOptions), |
| 215 | Effect.mapError((error) => |
| 216 | new DocgenError({ |
| 217 | message: `[Configuration.readTSConfig] Failed to read TSConfig file\n${String(error)}` |
| 218 | }) |
| 219 | ), |
| 220 | Effect.orDie |
| 221 | ) |
| 222 | ) |
| 223 | }) |
| 224 | |
| 225 | const loadCompilerOptions = (configKey: string) => |
| 226 | Config.string(configKey).pipe( |