effect-io-ai

Package: effect
Module: ConfigProvider

ConfigProvider.fromDotEnvContents

Creates a ConfigProvider by parsing the string contents of a .env file.

When to use

Use when you already have the .env contents as a string, such as contents fetched from a remote store or embedded in a test.

Details

Supports export prefixes, single/double/backtick quoting, inline comments, and escaped newlines. Variable expansion (for example, ${VAR}) is disabled by default; enable with { expandVariables: true }.

Literal empty strings are treated as missing values when loaded as values by default. Pass { preserveEmptyStrings: true } to keep empty strings as explicit values. Child discovery still reflects the keys present in the parsed .env source.

Parsing is based on the dotenv / dotenv-expand algorithm.

Internally delegates to fromEnv with the parsed key-value pairs.

Example (Parsing .env contents)

import { ConfigProvider } from "effect"

const contents = `
HOST=localhost
PORT=3000
# this is a comment
`

const provider = ConfigProvider.fromDotEnvContents(contents)

See

Signature

declare const fromDotEnvContents: (lines: string, options?: { readonly expandVariables?: boolean | undefined; readonly preserveEmptyStrings?: boolean | undefined; }) => ConfigProvider

Source

Since v4.0.0