c12 icon indicating copy to clipboard operation
c12 copied to clipboard

Implement override functionality in setupDotEnv and loadDotEnv functions

Open abhi12299 opened this issue 1 year ago • 0 comments

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

Issue Description

  • setupDotEnv function is called with a .env file. Assume that the only env var loaded is FLAG.
  • The FLAG variable's value is updated in the .env file by the running process.
  • setupDotEnv is called again, but the value of process.env.FLAG is not changed.

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.

abhi12299 avatar Sep 11 '24 07:09 abhi12299