mergeWithEnv
Merge the loaded configuration with environment variables whose names start with a given prefix. Config file values take precedence over environment variables — env vars only fill in keys that are missing from the config.
Matching env var names are:
- Stripped of the prefix
- Lowercased
- Split on
_to produce a nested object path
For example, with prefix SWML_, SWML_SERVER_PORT=3000 produces
{ server: { port: "3000" } }.
All values inherited from env vars are written as strings (Node returns
process.env values as strings). Apply
substituteVars() to the result if you need type
coercion.
Parameters
envPrefix
Prefix for environment variables to consider.
Returns
Record<string, unknown> — the merged configuration (file + prefixed env
vars) with ${VAR} substitution applied to file values.