@vltpkg/config
Config utilities for the vlt client.
Usage · API
Overview
These are config utilities used by the vlt cli.
Usage
import { get, set, edit, list, del } from '@vltpkg/config'
const colorValue = await get(conf)
await set(conf)
await edit(conf)
const allConfig = list(conf)
await del(conf)
API
get(conf: LoadedConfig)
- Retrieves a single config value by key
- Supports dot notation for accessing nested properties in record
fields
- Returns the value as
string | number | boolean | string[] | Record<string, string> | undefined
- Requires exactly one key in
conf.positionals[1]
set(conf: LoadedConfig)
- Sets config values from key=value pairs in
conf.positionals
- Creates an empty config file if no pairs are provided
- Supports dot notation for record fields (e.g.,
registry.npmjs.org=value)
- Writes to the config file specified by
conf.get('config')
edit(conf: LoadedConfig)
- Opens the config file in the editor specified by
conf.get('editor')
- Uses
spawnSync to launch the editor with the config file path
- Throws an error if the editor command fails
list(conf: LoadedConfig)
- Returns all current config options as an array of 'key=value'
strings
- Converts the internal config records to a flat list format
del(conf: LoadedConfig)
- Deletes specified config keys from the config file
- Requires at least one key in
conf.positionals (after the command
name)
- Removes keys from the file specified by
conf.get('config')