nodejs / nodejs/node

Support variable expansion in DotEnv features

Offen
#65,705 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

dotenv feature request
Vorherrschende Sprache
JavaScript
Sterne
122k
Forks
37.3k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
283

Beschreibung

What is the problem this feature will solve?

Sometimes it's helpful to derive the value of variables from other variables, using variable expansion.

For example, consider the following .env file:

APPLICATION_PORT: 8080
BASE_URL: http://localhost:8080

The APPLICATION_PORT and BASE_URL should have the same port. For reasons external to this issue, BASE_URL cannot be split into two variables without causing confusion.

If there are external overrides to APPLICATION_PORT, they won't remain in sync with BASE_URL.

What is the feature you are proposing to solve the problem?

Instead we could write .env files like this:

APPLICATION_PORT: 8080
BASE_URL: http://localhost:${APPLICATION_PORT}

This is already supported by at least bash, and the concept of variable expansion in environmental configuration is also common in ecosystems such as Kubernetes.

What alternatives have you considered?
  • Using dotenvx
  • Splitting variables up into their lowest common set

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue nennt keine Dateien oder Tests; beginne damit, die DotEnv-Implementierung von Node und ihre bestehende Testabdeckung zu lokalisieren. Verfolge, wie Werte geparst und aufgelöst werden, und definiere anschließend Tests für die Expansion von ${APPLICATION_PORT} sowie das erwartete Verhalten bei Überschreibungen und der Reihenfolge. Erledigt ist die Aufgabe, wenn das vorgeschlagene Expansionsverhalten implementiert und durch Tests abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript
Bereich
backend
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
52/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.