keithmorris / node-dotenv-extended

A module for loading .env files and optionally loading defaults and a schema for validating all values are present.
MIT License
111 stars 24 forks source link

Fix process.env overrided by default using cli #19

Closed gabrielDevlog closed 4 years ago

gabrielDevlog commented 6 years ago

Why Using cli, process.env is overrided by .env.defaults. Expected behavior is the opposite.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 353614b244b4f56f7842d348b8aad05847311ca6 on lonestone:develop into c5b3a4206d654077e462b90bb83c59c1e925cdc7 on keithmorris:develop.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 353614b244b4f56f7842d348b8aad05847311ca6 on lonestone:develop into c5b3a4206d654077e462b90bb83c59c1e925cdc7 on keithmorris:develop.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 353614b244b4f56f7842d348b8aad05847311ca6 on lonestone:develop into c5b3a4206d654077e462b90bb83c59c1e925cdc7 on keithmorris:develop.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 353614b244b4f56f7842d348b8aad05847311ca6 on lonestone:develop into c5b3a4206d654077e462b90bb83c59c1e925cdc7 on keithmorris:develop.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 343e85770f4564cfb565d17897b0b8f73683da0f on lonestone:develop into c5b3a4206d654077e462b90bb83c59c1e925cdc7 on keithmorris:develop.

gabrielDevlog commented 6 years ago

What about this MR ? Is this fixed now ?

keithmorris commented 6 years ago

@GitBalou sorry for the late response to this.

I believe the library is working as designed. There is an option to overrideProcessEnv which will override the values in process.env with the values from .env and .env.defaults. Also, looking at the submitted code you sent, this returns the actual process.env variables mixed with the .env values.

Not sure exactly what you're trying to accomplish. If you set the overrideProcessEnv to true, this will make sure that all variables in the .env are in the process.env variables as well as overwrite them. Otherwise, it will not. By design, the returned config data does not contain the process.env variables (which your commit changes)

Can you give me more details on what you're trying to accomplish and I may be able to help out.