Home / Function/ mergeEnvContent() — ui Function Reference

mergeEnvContent() — ui Function Reference

Architecture documentation for the mergeEnvContent() function in env-helpers.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  b18653bf_101d_ca3f_a9c5_a3788a04e629["mergeEnvContent()"]
  6ea7c0f6_8e34_1742_bb2f_90e611bb6eda["env-helpers.ts"]
  b18653bf_101d_ca3f_a9c5_a3788a04e629 -->|defined in| 6ea7c0f6_8e34_1742_bb2f_90e611bb6eda
  f6d1e24d_2a4b_80a5_233e_1b31060a0b05["parseEnvContent()"]
  b18653bf_101d_ca3f_a9c5_a3788a04e629 -->|calls| f6d1e24d_2a4b_80a5_233e_1b31060a0b05
  style b18653bf_101d_ca3f_a9c5_a3788a04e629 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/env-helpers.ts lines 83–113

export function mergeEnvContent(existingContent: string, newContent: string) {
  const existingEnv = parseEnvContent(existingContent)
  const newEnv = parseEnvContent(newContent)

  let result = existingContent.trimEnd()
  if (result && !result.endsWith("\n")) {
    result += "\n"
  }

  const newKeys: string[] = []
  for (const [key, value] of Object.entries(newEnv)) {
    if (!(key in existingEnv)) {
      newKeys.push(`${key}=${value}`)
    }
  }

  if (newKeys.length > 0) {
    if (result) {
      result += "\n"
    }
    result += newKeys.join("\n")
    return result + "\n"
  }

  // Ensure existing content ends with newline.
  if (result && !result.endsWith("\n")) {
    return result + "\n"
  }

  return result
}

Subdomains

Frequently Asked Questions

What does mergeEnvContent() do?
mergeEnvContent() is a function in the ui codebase, defined in packages/shadcn/src/utils/env-helpers.ts.
Where is mergeEnvContent() defined?
mergeEnvContent() is defined in packages/shadcn/src/utils/env-helpers.ts at line 83.
What does mergeEnvContent() call?
mergeEnvContent() calls 1 function(s): parseEnvContent.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free