Skip to content

buildConfigSearchPaths

Generated reference page for the buildConfigSearchPaths function export.

Signatures

ts
function buildConfigSearchPaths(appName: string, options: ConfigSearchPathOptions): readonly string[];
ParameterTypeDescription
appNamestringCLI application name used to derive config filenames.
optionsConfigSearchPathOptionsDirectory scopes and loaders (see ConfigSearchPathOptions).

Members

Members

buildConfigSearchPaths

Build the default config search paths for an app.

Advanced helper used by DreamCLI's config discovery. Most apps should call .config() or discoverConfig instead of constructing search paths manually. Exported for debugging, custom discovery flows, and help text.

Search order (first match wins):

  1. Project scope — for baseDir and each ancestor directory up to the filesystem root, nearest first:
    1. {dir}/.{appName}.json — dotfile
    2. {dir}/{appName}.config.json — explicit config
    3. {dir}/.config/{appName}.json — project .config/ convention
  2. User scope — {userConfigDir}/{appName}/config.json for each entry of userConfigDirs, in order.
  3. System scope — {systemConfigDir}/{appName}/config.json for each entry of systemConfigDirs, in order.

When custom loaders are registered, each path pattern is repeated per supported extension (JSON always first).

ts
(appName: string, options: ConfigSearchPathOptions): readonly string[];

Examples

ts
const paths = buildConfigSearchPaths('mycli', {
  baseDir: '/repo/packages/app',
  userConfigDirs: ['/home/me/.config'],
  systemConfigDirs: ['/etc'],
});

See Also

Released under the MIT License.