MCPcopy Create free account
hub / github.com/Effect-TS/effect / fromDotEnvContents

Function fromDotEnvContents

packages/effect/src/ConfigProvider.ts:1046–1055  ·  view source on GitHub ↗
(lines: string, options?: {
  readonly expandVariables?: boolean | undefined
  readonly preserveEmptyStrings?: boolean | undefined
})

Source from the content-addressed store, hash-verified

1044 * @since 4.0.0
1045 */
1046export function fromDotEnvContents(lines: string, options?: {
1047 readonly expandVariables?: boolean | undefined
1048 readonly preserveEmptyStrings?: boolean | undefined
1049}): ConfigProvider {
1050 let env = parseDotEnvContents(lines)
1051 if (options?.expandVariables) {
1052 env = dotEnvExpand(env)
1053 }
1054 return fromEnvRecord(env, { preserveEmptyStrings: options?.preserveEmptyStrings })
1055}
1056
1057const DOT_ENV_LINE =
1058 /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg

Callers 1

ConfigProvider.tsFile · 0.85

Calls 3

parseDotEnvContentsFunction · 0.85
dotEnvExpandFunction · 0.85
fromEnvRecordFunction · 0.85

Tested by

no test coverage detected