env2 icon indicating copy to clipboard operation
env2 copied to clipboard

Feature: Return env as Object

Open nelsonic opened this issue 5 years ago • 0 comments

Story

As a person wanting to know which which environment variables were in the .env file I would like to have the environment variables that were in the .env file returned as an Object So that I can check if the var was loaded from a file or from another place.

Currently in our usage instructions: https://github.com/dwyl/env2#use-in-your-code image We hint at the possibility that the environment variables loaded by env2 are assigned to the env constant:

const env = require('env2')('./path-to-your/.env');

But reading the code we can see that no such Object is being returned: https://github.com/dwyl/env2/blob/15a8bd4fa0a35647e21bc1107f1655a1bf0f4f6e/lib/env.js#L57-L60

We could return the env on line 38 and it would (before the catch statement): https://github.com/dwyl/env2/blob/15a8bd4fa0a35647e21bc1107f1655a1bf0f4f6e/lib/env.js#L32-L38

This would not alter the existing functionality of the package and would add this feature.

nelsonic avatar Feb 12 '20 10:02 nelsonic