dwyl / dwyl/env2

Feature: Return env as Object

Open
#53 0 comments 1 reaction 0 assignees View on GitHub
enhancement T25m technical
Dominant language
JavaScript
Stars
102
Forks
8
PR merge metrics
No merged PRs in 30d

Description

# 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](https://github.com/dwyl/env2/tree/15a8bd4fa0a35647e21bc1107f1655a1bf0f4f6e#use-in-your-code)
![image](https://user-images.githubusercontent.com/194400/74323414-650fb380-4d7d-11ea-9bcb-d2d756bb7bd9.png)
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.