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

Function fromEnv

packages/effect/src/ConfigProvider.ts:955–973  ·  view source on GitHub ↗
(options?: {
  readonly env?: Record<string, string> | undefined
  readonly preserveEmptyStrings?: boolean | undefined
})

Source from the content-addressed store, hash-verified

953 * @since 2.0.0
954 */
955export function fromEnv(options?: {
956 readonly env?: Record<string, string> | undefined
957 readonly preserveEmptyStrings?: boolean | undefined
958}): ConfigProvider {
959 if (options?.env !== undefined) {
960 return fromEnvRecord(options.env, options)
961 }
962 let provider: ConfigProvider | undefined
963 return make((path) =>
964 Effect.suspend(() =>
965 (provider ??= fromEnvRecord({
966 ...(globalThis as {
967 readonly process?: { readonly env?: Record<string, string | undefined> }
968 }).process?.env,
969 ...(import.meta as any)?.env
970 }, options)).load(path)
971 )
972 )
973}
974
975type EnvTrieNode = {
976 children?: Record<string, EnvTrieNode>

Callers 1

ConfigProvider.tsFile · 0.85

Calls 3

fromEnvRecordFunction · 0.85
makeFunction · 0.70
loadMethod · 0.65

Tested by

no test coverage detected