MCPcopy Create free account
hub / github.com/Effect-TS/effect / readTSConfig

Function readTSConfig

packages/tools/docgen/src/Configuration.ts:203–223  ·  view source on GitHub ↗
(fileName: string)

Source from the content-addressed store, hash-verified

201}
202
203const 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
225const loadCompilerOptions = (configKey: string) =>
226 Config.string(configKey).pipe(

Callers 1

resolveCompilerOptionsFunction · 0.85

Calls 5

pipeMethod · 0.65
pipeFunction · 0.50
StringInterface · 0.50
parseMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected