Skip to content

feat: resolve variable references in source .env before writing to project .env #10

Description

@castastrophe

Problem

When a user's ~/.env contains values like:

DB_HOST=localhost
DB_PORT=5432
DATABASE_URL=${DB_HOST}:${DB_PORT}/dev

envoy currently copies ${DB_HOST}:${DB_PORT}/dev literally into the project .env. The resolved value — localhost:5432/dev — is what the project actually needs.

Proposed behavior

Before writing a value to the project .env, envoy resolves any variable references ($VAR or ${VAR}) found in the source value against the other keys present in ~/.env. The resolved string is written, not the template.

Resolution should:

  • Follow the same left-to-right, defined-before-use ordering as shell variable expansion
  • Detect and warn on circular reference loops rather than hanging
  • Leave unresolvable references as-is (same non-destructive fallback behavior as missing keys today)

Open questions

  • Should resolution be opt-in via a flag (--resolve-vars) or always-on?
  • How should nested references (variables that reference other variables) be handled?
  • Should the resolution order be explicitly documented?

Related

Part of the feature roadmap.

Metadata

Metadata

Assignees

Labels

featA new feature or request (minor release)

Fields

Priority

High

Effort

Average

Target date

None yet

Projects

Status
Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions