Skip to content

discoverConfig

Generated reference page for the discoverConfig function export.

Signatures

ts
function discoverConfig(appName: string, adapter: ConfigAdapter, options?: ConfigDiscoveryOptions): Promise<ConfigDiscoveryResult>;

Members

Members

discoverConfig

Discover and load a config file.

Low-level discovery helper behind CLIBuilder.config(). Most apps should let the CLI runtime call this automatically; call it directly when testing config behavior or building custom bootstrapping around RuntimeAdapter.

Pure function — all filesystem I/O flows through adapter.readFile. Returns a discriminated union: { found: true, ... } when a config file was found and parsed, { found: false } when no file exists.

ts
(appName: string, adapter: ConfigAdapter, options?: ConfigDiscoveryOptions): Promise<ConfigDiscoveryResult>;

Examples

ts
const result = await discoverConfig('mycli', adapter, {
  loaders: [
    configFormat(['yaml', 'yml'], Bun.YAML.parse),
    configFormat(['toml'], Bun.TOML.parse),
  ],
});

See Also

Released under the MIT License.