unjs / c12

⚙️ Smart Configuration Loader
MIT License
537 stars 19 forks source link

Implement override functionality in setupDotEnv and loadDotEnv functions #190

Open abhi12299 opened 2 months ago

abhi12299 commented 2 months ago

This is an issue related to a draft PR I raised in https://github.com/nuxt/cli/pull/466

Issue Description

Reproduce the issue: https://stackblitz.com/edit/stackblitz-starters-xnps4y?file=.env,index.js

I have introduced an override flag in DotenvOptions, which gives precedence to the env variable values in the .env file over the existing values in process.env.

With this change, the PR https://github.com/nuxt/cli/pull/466 can be simplified and we can use this new flag directly.