Config file discovery. Resolves where config files live for a project, walking up from the working directory to the worktree root plus the global config directory, and reads individual config files tolerantly.

Members

(static, constant) directories

Effect that resolves the deduplicated list of config directories to consult: the global config dir, any .closedcode dirs found between directory and the worktree root (unless project config is disabled) plus one in the home dir, and an explicit override directory when configured.

(static, constant) files

Effect that finds <name>.jsonc/<name>.json config files by walking up from a directory to the worktree root, returned outermost-first (root before nested).

Methods

(static) fileInDirectory(dir, name) → {Array.<string>}

Build the candidate .json and .jsonc paths for a config file in a directory.

Parameters:
NameTypeDescription
dirstring

The directory to look in.

namestring

The config file base name (without extension).

Returns:

The [<dir>/<name>.json, <dir>/<name>.jsonc] candidate paths.

Type: 
Array.<string>

(static) readFile(filepath) → {Promise.<(string|undefined)>}

Read a config file, returning undefined for missing files and throwing JsonError for other failures.

Parameters:
NameTypeDescription
filepathstring

Absolute path to the config file.

Throws:

When the file exists but cannot be read.

Type
JsonError
Returns:

The file contents, or undefined when the file does not exist.

Type: 
Promise.<(string|undefined)>