Skip to content

buildConfigSearchPaths ​

Generated reference page for the buildConfigSearchPaths function export.

Signatures ​

ts
function buildConfigSearchPaths(appName: string, cwd: string, configDir: string, loaders?: readonly FormatLoader[]): readonly string[];
ParameterTypeDescription
appNamestringCLI application name used to derive config filenames.
cwdstringCurrent working directory (project-root search location).
configDirstringPlatform config directory (XDG / AppData).
loadersreadonly FormatLoader[] | undefinedOptional custom FormatLoaders whose extensions expand the search set.

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. $CWD/.{appName}.json — dotfile in project root
  2. $CWD/{appName}.config.json — explicit config in project root
  3. $CONFIG_DIR/{appName}/config.json — XDG / AppData standard ($XDG_CONFIG_HOME / ~/.config on Unix, %APPDATA% / %USERPROFILE%\\AppData\\Roaming on Windows)

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

ts
(appName: string, cwd: string, configDir: string, loaders?: readonly FormatLoader[]): readonly string[];

Examples ​

ts
const paths = buildConfigSearchPaths('mycli', '/repo', '/home/me/.config');

See Also ​

Released under the MIT License.