c12
c12 copied to clipboard
Implement override functionality in setupDotEnv and loadDotEnv functions
This is an issue related to a draft PR I raised in https://github.com/nuxt/cli/pull/466
Issue Description
setupDotEnvfunction is called with a.envfile. Assume that the only env var loaded isFLAG.- The
FLAGvariable's value is updated in the.envfile by the running process. setupDotEnvis called again, but the value ofprocess.env.FLAGis 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.